简体   繁体   English

jQuery UI对话框,打开新对话框并关闭后面的对话框

[英]jquery ui dialog, open new dialog and close dialog behind

My Site has a footer that open 4 different dialogs and load content to them from independent pages. “我的网站”的页脚可打开4个不同的对话框,并从独立页面将内容加载到其中。

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. 1.dialog在另一个对话框的顶部打开。

2.dialog opens from an independent page. 2.dialog从一个独立页面打开。

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. 谢谢。

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();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM