Dialog will move its div-tag to body

Dialog will move its div-tag to body

Hello,

If a dialog is opened and destroyed the div used as dialogcontent will be removed from its original position and will be appended to the body. This becomes a problem when using partial page updates, because the div will move out of the scope of the update. If the update creates the div again it will exist twice now, including all the problems like not unique IDs.

I have got two ideas to fix this.

Alternative 1: Memorize the parent element
Add following line to the _create function
  1.     this.parentElement = this.element.context.parentNode;
In open function it can be used like this
  1.     uiDialog.appendTo(this.parentElement);
And in the destroy function
  1.     .hide().appendTo(this.parentElement);

Alternative 2: Set the target element as option
A new option could look like
  1.     parentElement: 'body'
In open function it can be used like this
  1.     uiDialog.appendTo(self.options.parentElement);
And in the destroy function
  1.     .hide().appendTo(self.options.parentElement);

<edit>
For a dialog, that is not autoopening an additional code modification is needed

In _create function:
  1.             uiDialog = (self.uiDialog = $('<div></div>'))
  2.                 .appendTo(this.parentElement)
</edit>

Tested with JQuery UI Version 1.8.1

Greetings,
MaKraus