Click here to Skip to main content
12,622,032 members (32,621 online)
Rate this:
 
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 22: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 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 13-Feb-13 5:38am
   
:-)
Member 10732178 22-Jul-14 3:12am
   
thankssss a lot !!
vinodkumarnie 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2016
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