I stumbled upon a tricky situation. In my app, I use UI Dialogs based
on my <form>'s. When a dialog is created, it takes the <form> out of
the HTML context where it was originally located, moves before the
closing </body> tag and wraps it with all these dialog divs, buttons
etc. But when my AJAX calls replace body content with a new HTML, the
problem occurs that now I have TWO identical forms in the DOM: one
that was just returned with AJAX call, and another one that remains in
this "ghost" dialog stuck in the end of the body. This makes a mess
and also leads to creating duplicated dialogs...

So, before creating a dialog, I previously had to check for existence
of those "ghost" dialogs:

if ($('.ui-dialog '+pid).length) $('.ui-dialog '+pid).parents('.ui-
dialog').remove();

where pid is the id of my <form> that the dialog is made of.

Now, after upgrading to 1.5b4, it turned out that remove() works
differently! It doesn't remove the $('.ui-dialog '+pid).parents('.ui-
dialog'), which is a main dialog div, from DOM! Instead, it kinda
destroys the dialog, stripping all its divs and buttons, and leaving
my original <form> "hanging in the air", still stuck in the end of the
body...

Maybe it's because UI Dialogs have their own remove() method and it
"replaces" general jQuery remove-from-DOM method?

Reply via email to