Reputation: 49
My Site has a footer that open 4 different dialogs and load content to them from independent pages.
The footer pages can be opened independently if you enter them from search engine or type the url.
I have a function that opens the footer dialogs:
function FooterPopup(){
$(document).ready(function(){
$('#footerContactUs').on("click",function(){
var $dialog=$('<div></div>').load($('#footerContactUs').attr('href')).dialog({
close: function(event,ui){$(this).remove ();},
autoOpen:false,
width:700,
height:610,
resizable:'false',
modal:true,
show:'blind',
hide:{effect:'blind',duration:300},
dialogClass:'Contact'
});
$dialog.dialog('open');
return false;
});
})
}
The independent pages have link that open another dialog in a different function,
so I have 2 situations:
1.dialog opens on top of another dialog.
2.dialog opens from an independent page.
code:
function Consult(){
$(document).ready(function(){
$('.ConsultHotels').on("click",function(){
var $dialog=$('<div></div>').load($('.ConsultHotels').attr('href')).dialog({
modal:true,
close: function(event,ui){$(this).remove();
$('.ui-datepicker').remove();},
autoOpen:false,
width:750,
height:590,
resizable:'false',
show:'blind',
hide:{effect:'blind',duration:300},
open:function(event,ui){$('body').find('.ui-dialog-content').eq(0).dialog("close");},
dialogClass:'ConsultClass'
});
$dialog.dialog('open');
return false;
});
});
}
My problem is that I dont Know how to close the "parent" dialog from the first situation without closing the dialog in the second situation.
Please help,
Thanks.
Upvotes: 0
Views: 3764
Reputation: 3247
Why not just close any open dialogs before opening the new dialog?
$('.ConsultHotels').on("click",function(){
// first close any open dialogs. This approach is used in stead of just doing a .hide()
// because it will invoke any dialog close callbacks.
$('.ui-dialog-titlebar-close:visible').click();
// now initialize your dialog.
var $dialog = $('<div></div>').load($('.ConsultHotels').attr('href')).dialog();
});
Upvotes: 1