Opened 11 years ago

Closed 11 years ago

Last modified 7 years ago

#3264 closed feature (worksforme)

Destroying dialog with all of its contents

Reported by: skorpan Owned by: Scott González
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'); });

Change History (4)

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

Resolution: worksforme
Status: newclosed

Just remove the content normally:

$(el).remove();

comment:2 Changed 11 years ago by skorpan

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

comment:3 Changed 11 years ago by ThrushAAX

just do

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

comment:4 Changed 7 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.