我试图在提交表单之前显示 jquery 的对话框确认。但是只有在提交表单时我才能弹出它,这是代码:
$(function remove() {
$("#dialog-confirm").dialog({
resizable: false,
height:200,
modal: true,
buttons: {
'Delete campaign': function() {
return true ;
$(this).dialog('close');
},
Cancel: function() {
return false;
$(this).dialog('close');
}
}
});
});
对话框确认内容
<div id="dialog-confirm" title="Delete ?" style="display:none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
表单提交内容
<form style="display: inline;" action="remove.php" method="post"" onsubmit="return remove()">