I'm having an issue using jQuery Tools Tabs (AJAX) along with jQuery UI Dialog (manually doing the AJAX loading for the dialog). The issue is that the dialog is loaded and setup specifically for the current tab (loaded on the tab request via AJAX, along with the tab's content). jQuery UI, when creating the dialog, removes the container from it's original position, adds its markup, and appends it to the body.
The issue is that the dialog is now outside of the tab's content and will not get replaced/removed on subsequent tab changes. If the user clicks another tab, or the back button (these tabs have an AJAX history using the URL hash, so the page is not actually reloaded), the dialog is broken but doesn't get removed since jQuery UI Dialog moved it outside of the tab content. It now just shows up at the bottom of the body. I wrote a 'hack around' for this if the user physically clicks the close button, but this doesn't get fired if the back button is pressed or another tab is loaded via AJAX and jQuery UI actually MOVES IT BACK to the bottom of the body (Not sure how/why it does that!). Any suggestions? And please let me know if I wasn't clear on any of that. Thanks! (Here's what I've got now, that successfully removes it when the users physically closes the dialog)
$('.openMyDialog').click(function() {
// Create div for dialog
$('body').append('<div id="modalContainer"></div>');
// Load dialog with AJAX
$('#modalContainer').load('loadMyAjaxContent.html').dialog({
modal: true,
width: 850,
open: function(type,data) {
// Remove from bottom of body and put it back into the tab's content
$(this).parent().appendTo('.panes div:first');
},
close: function() {
$(this).dialog('destroy');
$('#modalContainer').remove();
}
});
});