我在论坛上发现了同样的问题,但无论如何都无法解决 我有一个登录表单。类似的东西:
@using (Ajax.BeginForm("LogIn", "Account", null, new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = "result",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "loginspinner",
OnSuccess = "OnTryLogin"
}, new { id = "loginform"}))
{
<div>
<div class="editor-field">
@Html.TextBoxFor(m => m.UserName, new { id = "loginusername"})
@Html.ValidationMessageFor(m => m.UserName)
</div>
..............................
我显示popup(partialview),如:
$.get(loginaction, function (data) {
var div;
var divId = '#popupforlogin';
div = $(divId);
$(div).html(data);
$(div).dialog({
modal: true,
resizable: false,
autoOpen: false,
});
$(div).dialog('open');
// ....
}
我有:
function OnTryLogin(result) {
if (result.success == true) {
var fullPath = '@Url.Content("~/Account")' + '/LogOff';
var userName = result.userName;
$('#popupforlogin').dialog('close');
//......
}
所以问题是dialog('close')
无效。
我错在哪里?
答案 0 :(得分:1)
你实际上应该使用$('#popupforlogin').dialog({ autoOpen: false });
来初始化它。然后,您可以使用$('#popupforlogin').dialog('open');
打开对话框,然后$('#popupforlogin').dialog('close');
关闭它。
来自here