我正在使用 JQuery $.dialog()
,我在其中打开一个带有 OK 和 Cancel 按钮的对话框。
我原以为当对话框打开时,代码会停止,然后在用户选择“确定”或“取消”时首先继续。
这是我的完整源代码 http://pastebin.com/uw7bvtn7
我遇到问题的部分位于第 127-151 行。
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
resizable: false,
height: 600,
modal: true,
open: function() {
$(this).children('div.dialog-text').replaceWith("<h3><b>Users</b></h3>" + makeDialogTable(users) + "<h3><b>Owners</b></h3>" + makeDialogTable(owners));
},
buttons: {
"Okay": function() {
$(this).dialog("close");
},
Cancel: function() {
is_okay = 0;
$(this).dialog("close");
}
} // buttons
}); // dialog
alert(is_okay);
代码现在所做的是首先显示对话框,然后显示alert(is_okay)
顶部。
我想要的是,当用户按下 OK 或 Cancel 时,代码首先会继续。
那怎么可能呢?