Search and Top Navigation
#5730 closed enhancement (wontfix)
Opened June 15, 2010 07:47PM UTC
Closed June 15, 2010 08:07PM UTC
Last modified October 11, 2012 09:15PM UTC
Dialog destroy option to destroy self.element
Reported by: | cmathis430 | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.dialog | Version: | 1.8.2 |
Keywords: | destroy | Cc: | |
Blocked by: | Blocking: |
Description
For dialogs created with anonymous content, it would be nice to have an option to destroy the dialog along with the content.
Anonymous content dialog:
$('<div>Anonymous content</div>').dialog({ close: function() { $(this).dialog('destroy'); } });
I want to add a parameter to specify whether to remove the original content as well when calling destroy:
$(this).dialog('destroy', true);
Below is a change I made to allow this:
In jquery.ui.dialog.js line 164 I made the following change:
destroy: function(destroySelf) { var self = this; (self.overlay && self.overlay.destroy()); self.uiDialog.hide(); self.element .unbind('.dialog') .removeData('dialog') .removeClass('ui-dialog-content ui-widget-content'); if (!destroySelf) { self.element.hide().appendTo('body'); } self.uiDialog.remove(); (self.originalTitle && self.element.attr('title', self.originalTitle)); return self; },
Just use .remove() instead of .dialog( "destroy" ).