1

I have found on the forum the same issues but cannot fix it anyway I have a login form. Something like:

 @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>
..............................

I show popup (partialview) like:

$.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');
            // ....
}

And I have:

function OnTryLogin(result) {
            if (result.success == true) {
                var fullPath = '@Url.Content("~/Account")' + '/LogOff';
                var userName = result.userName;
                $('#popupforlogin').dialog('close');
                //......
}

so the problem is that dialog('close') is not working.

Where am I mistaken?

CodingGorilla
  • 19,612
  • 4
  • 45
  • 65
amplifier
  • 1,793
  • 1
  • 21
  • 55
  • *is not working* is not an explanation -- please add some kind of error message if you're getting any. If not, please let us know how you've tried to debug so far? – ahren Nov 27 '12 at 20:22
  • I mean dialog stays opened and I have no errors in the firebug console window. When I was debugging it went through a line "$('#popupforlogin').dialog('close');" without any errors – amplifier Nov 28 '12 at 03:28

1 Answers1

1

You're actually supposed to use $('#popupforlogin').dialog({ autoOpen: false }); to initialize it. Then you can use $('#popupforlogin').dialog('open'); to open the dialog, and $('#popupforlogin').dialog('close'); to close it.

from here

Community
  • 1
  • 1
Scott Selby
  • 9,420
  • 12
  • 57
  • 96