【发布时间】:2011-04-06 20:31:38
【问题描述】:
我正在使用 jQuery UI 对话框。我有一个删除表格如下:
@using (Ajax.BeginForm("DeleteUser", "Administrator", new { id = Model }, new AjaxOptions { OnSuccess = "Deleted", OnBegin = "DeletingUser" }, new { id = "frm" + Model, name = Model }))
{
<input type="submit" value="" />
}
我希望在发送ajax请求之前,弹出一个模态确认,用户选择是或否。
这是我的 javascript:
<script>
function DeletingUser(){
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
//I need to return a true or false here depending on the button clicked.
}
</script>
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
从 javascript 代码中可以看出,对话框是异步打开的,这会导致该方法不返回任何内容,并且无论如何都会提交表单,而无需用户选择是或否。我该如何解决这个问题?
【问题讨论】:
标签: javascript jquery asp.net-mvc asp.net-mvc-3