diff options
author | Alberto Monteiro <betimbrasil@gmail.com> | 2011-12-15 17:52:49 -0300 |
---|---|---|
committer | Alberto Monteiro <betimbrasil@gmail.com> | 2011-12-15 17:52:49 -0300 |
commit | a4b7feabd3aa59bbd5523a8a199b0afbce070d7f (patch) | |
tree | efe4bee3006f9cb8533e422b937d926447699de1 /ui/jquery.ui.dialog.js | |
parent | aa8c4770a9a88cc4a870f4adf33ba2466e30bfcf (diff) | |
download | jquery-ui-a4b7feabd3aa59bbd5523a8a199b0afbce070d7f.tar.gz jquery-ui-a4b7feabd3aa59bbd5523a8a199b0afbce070d7f.zip |
Dialog: When destroy is called place the element back in original DOM position. Fixed #4980 - Dialog: Destroy should place element back in original DOM position
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r-- | ui/jquery.ui.dialog.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 3d7638667..1f959a837 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -77,8 +77,11 @@ $.widget("ui.dialog", { // #5742 - .attr() might return a DOMElement if ( typeof this.originalTitle !== "string" ) { this.originalTitle = ""; - } - + } + this.oldPosition = { + parent: this.element.parent(), + index: this.element.parent().children().index( this.element ) + }; this.options.title = this.options.title || this.originalTitle; var self = this, options = self.options, @@ -168,7 +171,8 @@ $.widget("ui.dialog", { }, _destroy: function() { - var self = this; + var self = this, next, + oldPosition = this.oldPosition; if ( self.overlay ) { self.overlay.destroy(); @@ -183,6 +187,13 @@ $.widget("ui.dialog", { if ( self.originalTitle ) { self.element.attr( "title", self.originalTitle ); } + + next = oldPosition.parent.children().eq( oldPosition.index ); + if ( next.length ) { + next.before( self.element ); + } else { + oldPosition.parent.append( self.element ); + } }, widget: function() { |