Destroy dialog when original DOM parent is removed

When dialog is initialized inside a div which is then
being removed, dialog window remain open. In sophisticated
UI system this becomes problem, when dialog-based widgets
appear in other dialogs and remain after their parent-dialog
is removed.

Here is demo and alternative solution:
http://jsfiddle.net/gxXBY/

However this pull request would resolve issue