Removing a div that contains a dialog

Removing a div that contains a dialog


Is there any potential memory leaks if I remove a div element that may
contain a .dialog?
For example, if DOM is:
<div id='div1'>
I am a bunch of other content.
<div id='div2'>
I am a potential dialog.
</div>
</div>
Then this is called to make div2 a dialog:
$("#div2").dialog({autoOpen:false});
And later:
$("#div1").remove();
I've noticed that if you use the autoOpen option, the dialoged element
stays in it's original location. But once a .dialog("open") is called
on it, it is moved to the bottom of the DOM.
Here's another problem I am facing: I have a section of my DOM that
is used to load ajax content. This content may contain elements that
I wish to make dialogs. This same section will get emptied and loaded
with other ajax content. However, when a dialog has been opened it is
no longer in the DOM section that I am reloading. Even
calling .dialog("destroy") leaves the previously dialoged element
outside of it's original container.
I'm basically looking for a way to destroy the dialogs and remove the
original dialoged element at the same time. Any help would be
appreciated.
Thanks,
Dave