views:

23

answers:

1

I have a box with a link in it, and I have an event handler on the link that makes it create a jQuery dialog from the box when clicked. This part works fine. However, when I close the dialog, I want to restore the original box. It looked to me like .dialog("destroy") ought to do just that, since it's described as "returning the element to its pre-init state", but that's not working. Is there any way to do this without something silly like cloning the box before creating the dialog and then reinserting it?

A: 

I didn't have success with this too. My solution was:

var boxContainer = $('popupContainer');
$(this).find(popupClass).dialog({
   close: function(event, ui){
     boxContainer.append($(this).html());
     $(this).remove();
   },
   ....
});

It's working, although for me it's an "ugly" solution. Of course you can tune a little bit the example, but it's just my way.

Nik