Click here to Skip to main content
11,640,599 members (61,419 online)
Rate this: bad
good
Please Sign up or sign in to vote.
Hello.
I have an problem using my jquery UI dialog. If i click ones, it open perfect, but second time it opens twice and so on. I found different solutions. No have worked. Please help me
<a class="openLoginDialog" data-dialog-id="LoginDialog" data-dialog-title="Login" href="@Url.Action("LogOn", "Authentication", new { returnUrl = Request.Url.ToString() })">@Oline.Portal.Resources.Resources._headerlogin</a>
  $(".openLoginDialog").on("click", function (e) {
    e.preventDefault();
    $("<div></div>")
      .addClass("dialog")
      .attr("id", $(this).attr("data-dialog-id"))
      .appendTo("body")
      .dialog({
        title: $(this).attr("data-dialog-title"),
        create: function (event, ui) {},
        close: function () { $(this).remove() },
        open: function (event, ui) {},
        modal: true,
        position: ['center', 130],
        minWidth: 510,
        resizable: true,
        zIndex: 20000
      })
      .load(this.href);
  });
Posted 12-Feb-13 21:10pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Probably you are not closing the opened dialog properly...

In the above code you are creating dialog dynamically in each click event. So you should destroy(or delete) it before clicking to open it again.
Means on click of close delete the dialog.

Hope this is the case in your code...
  Permalink  
Comments
mortenstarck at 13-Feb-13 5:07am
   
Thanks for that. The solution was to add this two metodes $(this).unbind('click');
$('#openLoginDialog').dialog("destroy"); after e.preventDefault();
vinodkumarnie at 13-Feb-13 5:38am
   
:-)
Member 10732178 at 22-Jul-14 3:12am
   
thankssss a lot !!
vinodkumarnie at 22-Jul-14 9:34am
   
Welcome.. Happy coding.. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 310
1 OriginalGriff 165
2 Afzaal Ahmad Zeeshan 130
3 CPallini 109
4 Sergey Alexandrovich Kryukov 94
0 Mika Wendelius 200
1 OriginalGriff 145
2 CPallini 115
3 jgakenhe 40
4 sasanka sekhar panda 30


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100