jQuery-ui problem with modal dialog from ajax
Posted
by Intra
on Stack Overflow
See other posts from Stack Overflow
or by Intra
Published on 2010-05-25T23:44:38Z
Indexed on
2010/05/25
23:51 UTC
Read the original article
Hit count: 454
Hi
I have following setup
index.html with <div id="container"></div> using anchor method I load different html content into this container.
My content contains div for modal dialog "dialog-form" and I initialise it with the custom function from the javascript included in index.html on successful ajax load using callback
$.get("callback.php",query, function(data){ $("#container").html(data); initPos(); // here we run javascript to initialise modal dialog });Everything is ok until user click other menu (we load different content) and after that again clicks menu with this modal dialog, so page loads again, we call script again (everything is ok yet), dialog opens, information from the dialog is submitted to server and on sucessful sumbit I want to close the dialog with
('#dialog-form').dialog('close');it worked first time, but no longer works because we initialised this dialog twice and using Firebug I can see two different instances of modal dialog with the same name.
So, what is the right way to do the thing? Is there any way to close multiple dialogs with the same name or maybe we can kill all closed modal dialogs when user clicks different menu?
© Stack Overflow or respective owner