模式对话框
如想对话框显示为模式的,可以通过配置modal: true来设置。
5 |
< title >jQuery UI Demos</ title > |
6 |
< link rel = "stylesheet" href = "themes/trontastic/jquery-ui.css" /> |
7 |
< script src = "scripts/jquery-1.9.1.js" ></ script > |
8 |
< script src = "scripts/jquery-ui-1.10.1.custom.js" ></ script > |
11 |
$("#dialog-modal").dialog({ |
20 |
< div id = "dialog-modal" title = "Basic modal dialog" > |
22 |
Adding the modal overlay screen makes the dialog |
23 |
look more prominent because it dims out the page content. |
28 |
Sed vel diam id libero < a href = "http://example.com" >rutrum convallis</ a >. |
29 |
Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. |
30 |
Etiam bibendum, enim faucibus aliquet rhoncus, |
31 |
arcu felis ultricies neque, sit amet auctor elit eros a lectus. |

添加确认和取消按钮
可以通过配置主按钮,和从按钮的方法来为对话框添加按钮,此时如果需要把”X”从右上角去掉,可以通过CSS来实现,具体可以参考下例:使用dialogClass: “no-close”
5 |
< title >jQuery UI Demos</ title > |
6 |
< link rel = "stylesheet" href = "themes/trontastic/jquery-ui.css" /> |
7 |
< script src = "scripts/jquery-1.9.1.js" ></ script > |
8 |
< script src = "scripts/jquery-ui-1.10.1.custom.js" ></ script > |
10 |
.no-close .ui-dialog-titlebar-close { |
16 |
$("#dialog-confirm").dialog({ |
17 |
dialogClass: "no-close", |
23 |
"Delete all items": function () { |
24 |
$(this).dialog("close"); |
27 |
$(this).dialog("close"); |
36 |
< div id = "dialog-confirm" title = "Empty the recycle bin?" > |
39 |
< span class = "ui-icon ui-icon-alert" |
40 |
style = "float: left; margin: 0 7px 20px 0;" ></ span > |
41 |
These items will be permanently deleted |
42 |
and cannot be recovered. Are you sure? |
47 |
Sed vel diam id libero < a href = "http://example.com" >rutrum convallis</ a >. |
48 |
Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. |
49 |
Etiam bibendum, enim faucibus aliquet rhoncus, |
50 |
arcu felis ultricies neque, |
51 |
sit amet auctor elit eros a lectus. |
