我有一个模态。
我想以一种方式编写脚本,当用户点击取消或“转义”时,当文本框中输入任何信息时,它会提示他们保存未保存的信息。
我还需要弄清楚如何默认使用此方法的“添加/编辑执行信息”按钮:$(this).closest('。ui-dialog')。find('。ui-dialog-buttonpane 。按钮:当量(0)')聚焦();要关注按钮,但当用户在文本框中单击时,然后在文本框外部,它会取消按钮。
function ShowAddEditExecutive() {
$("#addEditExecutive").dialog({
modal: true,
width: 800,
appendTo: "form",
open: function () {
$(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button:eq(0)').focus();
$(this).dialog("widget").find(".ui-dialog-titlebar").show();
// Removes the do you want to leave this page dialog.
window.onbeforeunload = null;
// The two isplalines below are 2 different ways to ensure the
// background is completely grayed out if the modal is larger
// then the page. The first was chosen so that the scroll
// bars are not disabled.
$('.ui-widget-overlay').css('position', 'fixed');
//$('body').css('overflow', 'hidden');
},
buttons: {
"Add/Edit Executive Information": function () {
$("[id*=btnAddEditExecutive]").click();
},
"Cancel": function () {
if (confirm("Are you sure you want to cancel ?")) {
//code if yes
$(this).dialog("close");
}
}
},
close: function (ev, ui) {
// Ensures when you cancel that the values are not retained.
$(this).remove();
// The two lines below are 2 different ways to ensure the
// background is completely grayed out if the modal is larger
// then the page. The first was chosen so that the scroll
// bars are not disabled.
$('.ui-widget-overlay').css('position', 'absolute');
//$('body').css('overflow', 'inline');
},
});
}
答案 0 :(得分:0)
使用prompt()解决; Jquery命令