Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Created January 25, 2013 19:47
Show Gist options
  • Save Dillie-O/4637250 to your computer and use it in GitHub Desktop.
Save Dillie-O/4637250 to your computer and use it in GitHub Desktop.
Remove duplicate jQuery UI dialog objects before display.
// Thank you StackOverflow!!!
// http://stackoverflow.com/questions/7099938/jquery-ui-dialog-behaves-unpredictably
var original = $('#dialogId')[0];
var clone = $(original).clone().attr('id', 'dialogIdClone');
var saveHtml = $(original).html();
$(original).html('');
$(clone).dialog({
... // other options
open: function (){
// add any dynamic behavior you need to the dialog here
},
close: function(){
$(clone).remove();
$(original).html(saveHtml);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment