tags:

views:

27

answers:

1

Hi

I have a dialog that displays a form. When they save or close the dialog I call up the jquery dialog destroy method.

However I am not clear if it removes the html div. From the description I would not think so

Remove the dialog functionality completely. This will return the element back to its pre-init state.

However when looking with firebug I can't see the html container so I am not sure if it gets removed or what. I am not sure if it is because I make the div for the dialog on the fly and use jquery to add it to the page.

A: 

It does not destroy the HTML, you can see a demo here. However it does by default hide the container (leaving a display: none on there), so you need to .show() to see it again visually in the page if that's what you're after. Here's the simple demo test code:

<button>Create Dialog</button>
<div id="dialog">Test Content</div>

and the jQuery:

$("button").click(function() {
  $("#dialog").dialog({
    buttons: { 'Destroy Me': function() { $(this).dialog('destroy').show(); } }
  });
});

Running this you can toggle can element from being a dialog and back again.

Nick Craver
So I guess I should call the jquery remove then?
chobo2
@chobo2 - If you actually want the element gone then yes `.dialog('destroy').remove()` will work :)
Nick Craver