我点击了要么“是”或“否”的确认对话框OnSuccessForm后()函数不会触发。 如何制止继续之前onBeginForm()任何想法?
我MVC3表
@using (Ajax.BeginForm("Edit", @ViewContext.Controller.ValueProvider.GetValue("controller").RawValue, new AjaxOptions
{
UpdateTargetId = Model.Title.Replace(" ", "") + "Form",
InsertionMode = InsertionMode.Replace,
OnBegin = "onBeginForm",
OnSuccess = "OnSuccessForm",
OnFailure = "showFaliure"
}))
{
@Html.ValidationSummary(true)
@Html.RenderStandardEditor("Edit " + Model.Title)
}
这是我的JavaScript代码示例
<script type="text/javascript">
var confirmation = false;
function onBeginForm(ajaxContext)
{
$.confirm({
'title': 'Confirmation',
'message': 'Confirm?',
'buttons': {
'Yes': {
'class': 'cyan',
'action': function ()
{
confirmation = true;
}
},
'No': {
'class': 'gray',
'action': function ()
{
confirmation = false;
}
}
}
});
}
function OnSuccessForm(ajaxContext)
{
if (confirmation == true)
{
//DO SOMETHING
}
}
function showFaliure(ajaxContext)
{
//THROW ERROR
}
</script>