Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#5730 closed enhancement (wontfix)

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;
},

Change History (2)

comment:1 Changed 10 years ago by Scott González

Resolution: wontfix
Status: newclosed

Just use .remove() instead of .dialog( "destroy" ).

comment:2 Changed 8 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.