Skip to main content

Search and Top Navigation

#3264 closed feature (worksforme)

Opened August 29, 2008 08:58AM UTC

Closed August 30, 2008 09:13PM UTC

Last modified October 11, 2012 09:15PM UTC

Destroying dialog with all of its contents

Reported by: skorpan Owned by: scottgonzalez
Priority: minor Milestone:
Component: ui.dialog Version: 1.6b
Keywords: dialog, destroy, close, content Cc:
Blocked by: Blocking:
Description

I think there really should be some feature which can destroy dialogs and all of its contents in the same sweep. I think this is the way that most people expect the normal $.dialog('destroy') to work, but instead we have to first destroy the dialog and then also remove the content.

One possibility would be to create a new option called something like "destroyWithContent" which would be false by default (which would make it act like it does now) and another possibility would be to create a completely new "command" for it, such as $.dialog('destroyWithContent'). Either way, this is a must-have.

This is the way it works now:

// This code isn't tested, but it gives you the idea of how it works.

var content = $('<div><button id="closeDialog">Close</button></div>');
var d = content.dialog();
$('#closeDialog').click(function () {
    d.dialog('destroy');
    content.remove();
});

A better way would be:

// This code isn't tested, but it gives you the idea of how it works.

var content = $('<div><button id="closeDialog">Close</button></div>');
var d = content.dialog();
$('#closeDialog').click(function () { d.dialog('destroyWithContent'); });
Attachments (0)
Change History (4)

Changed August 30, 2008 09:13PM UTC by scottgonzalez comment:1

resolution: → worksforme
status: newclosed

Just remove the content normally:

$(el).remove();

Changed September 02, 2008 09:04AM UTC by skorpan comment:2

I'm not sure what you mean here. $(el), is that the dialog element or the contents in the dialog?

Changed September 08, 2008 08:55PM UTC by ThrushAAX comment:3

just do

$("#dialog").dialog("destroy").remove();

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:4

milestone: TBD

Milestone TBD deleted