I want to create a jQuery dialog from HTML returned by an AJAX call. This works, but “destroying” the dialog doesn’t remove the content from the div. What is the best way to completely remove the content?
Dialog creation code
$.get( 'mysite/dialogcontent', null,
function(data)
{
$(data).dialog( {
buttons: { 'OK' : function() { $(this).dialog('destroy'); } }
} );
} );
Possible solutions
- Manually find and remove the div
after calling .dialog(‘destroy’)? - Extend the destroy method and have
my version simply remove the
elements from the DOM? - Write a new method (kill?) that would do this.
I think calling
remove()on div that the dialog is created from should be the simplest one.