1. Calling
  2. Actions
  3. Settings
  4. Callbacks
  5. API

Calling

Here you add an actual call to the modal window. Clicking the "Open" button below will launch a modal with content of a #my-modal div. You can use buttons or links to open modals in Mikit. Clicking anywhere outside of the modal or hitting ESC will close the window.

// Call
<button data-component="modal" data-target="#my-modal">Open</button>

// Markup
<div id="my-modal" class="mi-modal-box mi-hide">
    <div class="mi-modal">
        <span class="mi-close mi-icon-close"></span>
        <div class="mi-modal-header">Modal Header</div>
        <div class="mi-modal-body">...</div>
    </div>
</div>

打开链接

// Call
<button data-component="modal" data-target="#ui-modal" data-url="modal.html">Open</button>

// Markup
<div id="ui-modal" class="modal-box mi-hide">
    <div class="mi-modal">
        <span class="mi-close mi-icon-close"></span>
        <div class="mi-modal-header">UI Modal</div>
        <div class="mi-modal-body">... content from modal.html ...</div>
    </div>
</div>

// modal.html
<p>...</p>
<a href="#" data-action="modal-close">Close</a>

Direct open

// Call
<button onclick="$.modalwindow({ target: '#ui-modal', url: 'modal.html' });">Open</button>
UI Modal
My Modal

汉皇重色思倾国,御宇多年求不得。杨家有女初长成,养在深闺人未识。天生丽质难自弃,一朝选在君王侧。回眸一笑百媚生,六宫粉黛无颜色。春寒赐浴华清池,温泉水滑洗凝脂。侍儿扶起娇无力,始是新承恩泽时。云鬓花颜金步摇,芙蓉帐暖度春宵。春宵苦短日高起,从此君王不早朝。

承欢侍宴无闲暇,春从春游夜专夜。后宫佳丽三千人,三千宠爱在一身。金屋妆成娇侍夜,玉楼宴罢醉和春。姊妹弟兄皆列土,可怜光彩生门户。遂令天下父母心,不重生男重生女。骊宫高处入青云,仙乐风飘处处闻。缓歌慢舞凝丝竹,尽日君王看不足。渔阳鼙鼓动地来,惊破霓裳羽衣曲。

九重城阙烟尘生,千乘万骑西南行。翠华摇摇行复止,西出都门百余里。六军不发无奈何,宛转蛾眉马前死。花钿委地无人收,翠翘金雀玉搔头。君王掩面救不得,回看血泪相和流。黄埃散漫风萧索,云栈萦纡登剑阁。峨嵋山下少人行,旌旗无光日色薄。蜀江水碧蜀山青,圣主朝朝暮暮情。

行宫见月伤心色,夜雨闻铃肠断声。天旋地转回龙驭,到此踌躇不能去。马嵬坡下泥土中,不见玉颜空死处。君臣相顾尽沾衣,东望都门信马归。归来池苑皆依旧,太液芙蓉未央柳。芙蓉如面柳如眉,对此如何不泪垂。春风桃李花开日,秋雨梧桐叶落时。西宫南内多秋草,落叶满阶红不扫。

......

临别殷勤重寄词,词中有誓两心知。七月七日长生殿,夜半无人私语时。在天愿作比翼鸟,在地愿为连理枝。天长地久有时尽,此恨绵绵无绝期。

Actions

Using modal-close action you now introducing a way to close you window, using a link or a button.

<div id="my-modal" class="mi-modal-box mi-hide">
    <div class="mi-modal">
        <span class="mi-close mi-icon-close"></span>
        <div class="mi-modal-header">Modal Header</div>
        <div class="mi-modal-body">
            ...
            <a href="#" data-action="modal-close">Close</a>
        </div>
    </div>
</div>

Settings

target

Defines a content layer for the modal window

url

Defines a URL in case your modal is opening via a URL.

header

Sets the header for the modal window. Optional, and is false by default.

width
height
maxHeight

This setting defines the maximum height of the window. A scrollbar will be introduced in case there's more text than maxHeight can accommodate.

position

This is where your modal appears when opened.

overlay

When this is set to false, you modal window will just appear on top ow your page, without an overlay effect. By default, your page will be "covered" with a semi-transparent layer when you open a modal.

animation

Turns opening and closing animation on and off.

Callbacks

open
$('#my-modal').on('open.modal', function()
{
    // do something...
});
opened
$('#my-modal').on('opened.modal', function()
{
    // do something...
});
close
$('#my-modal').on('close.modal', function()
{
    // do something...
});
closed
$('#my-modal').on('closed.modal', function()
{
    // do something...
});

API

You can use these API methods to programmatically operate and modify modal windows.

close
$('#my-modal').modal('close');
setHeader
$('#my-modal').modal('setHeader', 'My Header');

This is another way to set a header for the modal on the fly without introducing a div with a modal-header class.

setContent
$('#my-modal').modal('setContent', 'My Content');

Content of the modal window can be set up on the fly as well. No need for a div with modal class.

setWidth
$('#my-modal').modal('setWidth', '800px');