My solution only works if you are using Eric Martin's SimpleModal.
I found there is an option tag called persist that retains the DOM's elements. By default, this is set to false. Setting this to true will keep the DOM elements intact. Here's what Eric's site says:
persist [Boolean:false]
Persist the data across modal calls? Only used for existing DOM elements. If true, the data will be maintained across modal calls, if false, the data will be reverted to its original state.
Sample Code:
$('#hotelDetails').modal({
persist: true,
modal: false,
onOpen: function (dialog) {
dialog.overlay.fadeIn('fast', function () {
dialog.container.slideDown('fast', function () {
dialog.data.fadeIn('fast');
$('#tabs').tabs();
$("#tabs").tabs("option", "active", $("#" + atag).index());
});
});
},
onClose: function(dialog) {
dialog.data.fadeOut('fast', function () {
dialog.container.slideUp('fast', function () {
dialog.overlay.fadeOut('fast', function () {
$.modal.close(); // must call this!
$('#tabs').tabs("destroy");
});
});
});
},
zIndex: 3000
});