在 jQuery UI 对话框中,将modal
选项设置为 true,并使用该选项指定主要和次要用户操作buttons
。
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: [{
text: pm_info_msg_013,
click : function() {
$( this ).dialog( "close" );
// code related to "where_to_coupon== true" goes here
// submit form
}
}, {
text: "Cancel",
click: function() {
$( this ).dialog( "close" );
doSubmit = false;
// don't submit form
}}]
});
在此处查看演示:http: //jqueryui.com/demos/dialog/#modal-confirmation
更新:
这将允许您创建多个确认。用法:
function CreateDialog(okText, cancelText, okCallback, cancelCallback) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: [{
text: okText,
click : function() {
$( this ).dialog( "close" );
okCallback();
}
}, {
text: cancelText,
click: function() {
$( this ).dialog( "close" );
cancelCallback();
}}]
}
});
// ******* usage #1 ********
CreateDialog(pm_info_msg_013, "Cancel", function () {
// where_to_coupon== true
}, function() {
// where_to_coupon== false
});
function OnConfirmTrue() {
// do something
}
function OnConfirmFalse() {
// do something
}
// ******* usage #2 ********
CreateDialog(pm_info_msg_013, "Cancel", OnConfirmTrue, OnConfirmFalse);