[英]Confirm action for modal button asp.net
我試圖在用戶單擊下面的模式上的“取消”按鈕時添加提示。 它提示他們確認操作。 下面的代碼是我目前正在嘗試的。
function ShowAddEditExecutive() {
$("#addEditExecutive").dialog({
modal: true,
width: 800,
appendTo: "form",
open: function () {
$(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 () {
$(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');
},
});
}
如果您想創建一種確認操作的本機方式,則可以使用confirm
來提示用戶選擇繼續還是不執行,這就是您應該在代碼中執行的操作
"Cancel": function () {
if(confirm("Are you sure you want to cancel ?"))
{
//code if yes
$(this).dialog("close");
}
else
{
//code if no, don't do anything in your case, or don't use the else
}
}
這是用法示例 。
如果你想讓它看起來是一樣的你的設計,你可以創建一個自定義的其他方式<div>
其中包含的用戶是否同意要繼續或不確認文本,然后style
用它CSS
和使用jQuery onclick function
來處理事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.