jQuery dialog breaking after closing - I'm using dialog destroy
Posted
by pedalpete
on Stack Overflow
See other posts from Stack Overflow
or by pedalpete
Published on 2010-04-16T03:30:19Z
Indexed on
2010/04/16
3:33 UTC
Read the original article
Hit count: 401
I've got a few demo videos I've been making as tutorials, and I'm using a link to open a dialog box and put the demo video in that box.
I use the same div to show other notes on the page when a user selects to view a complete note.
The code I use to show the notes is
jQuery('span.Notes').live('click', function(){ var note=jQuery(this).data('note'); jQuery('div#showNote').text(note); jQuery('div#showNote').append('
'); jQuery('div#showNote').dialog({ modal: true, close: function(){ jQuery('div#showNote').dialog('destroy').empty(); } }); });
The code I use for the demo videos is VERY similar.
jQuery('a.demoVid').click(function(){ var videoUrl=jQuery(this).attr('href'); jQuery('div#showNote').dialog({ modal: true, height: 400, width: 480, close: function(){ jQuery('div#showNote').dialog('destroy').empty(); } }); swfobject.embedSWF(videoUrl,'showNote','480','390','8.0.0'); return false; });
I can click on as many notes as I want, and the dialog opens up and shows the note. However, when I click the demoVid, the dialog opens, but then closing the dialog kills any other 'showNote' dialogs on the page, so I can't open any more notes, or demo videos.
© Stack Overflow or respective owner