Javascript jQuery UI:如何打开/关闭由另一个对话框打开的对话框?

Javascript jQuery UI:如何打开/关闭由另一个对话框打开的对话框?,javascript,jquery,jquery-ui,dialog,overwrite,Javascript,Jquery,Jquery Ui,Dialog,Overwrite,index.php // load jquery.js and jquery.ui.js $("#dialog_a").load("template_a.php").dialog(); $("#dialog_b").load("template_b.php").dialog(); just HTML, no JS // !!! -> load jquery.js and jquery.ui.js <- !!! $("#dialog").load("template_c.php")

index.php

// load jquery.js and jquery.ui.js
$("#dialog_a").load("template_a.php").dialog();
$("#dialog_b").load("template_b.php").dialog();
just HTML, no JS
// !!! -> load jquery.js and jquery.ui.js <- !!!
$("#dialog").load("template_c.php").dialog({modal:true});
$(".anchor_in_dialog_or_not_doesnt_matter").live("click", function() {
    $("#dialog").dialog();
});
if ($_GET["standalone"])
    // load jquery, jquery.ui
endif;
模板a.php

// load jquery.js and jquery.ui.js
$("#dialog_a").load("template_a.php").dialog();
$("#dialog_b").load("template_b.php").dialog();
just HTML, no JS
// !!! -> load jquery.js and jquery.ui.js <- !!!
$("#dialog").load("template_c.php").dialog({modal:true});
$(".anchor_in_dialog_or_not_doesnt_matter").live("click", function() {
    $("#dialog").dialog();
});
if ($_GET["standalone"])
    // load jquery, jquery.ui
endif;
模板_b.php

// load jquery.js and jquery.ui.js
$("#dialog_a").load("template_a.php").dialog();
$("#dialog_b").load("template_b.php").dialog();
just HTML, no JS
// !!! -> load jquery.js and jquery.ui.js <- !!!
$("#dialog").load("template_c.php").dialog({modal:true});
$(".anchor_in_dialog_or_not_doesnt_matter").live("click", function() {
    $("#dialog").dialog();
});
if ($_GET["standalone"])
    // load jquery, jquery.ui
endif;
/!!!->加载jquery.js和jquery.ui.js解决方案:使用

index.php

// load jquery.js and jquery.ui.js
$("#dialog_a").load("template_a.php").dialog();
$("#dialog_b").load("template_b.php").dialog();
just HTML, no JS
// !!! -> load jquery.js and jquery.ui.js <- !!!
$("#dialog").load("template_c.php").dialog({modal:true});
$(".anchor_in_dialog_or_not_doesnt_matter").live("click", function() {
    $("#dialog").dialog();
});
if ($_GET["standalone"])
    // load jquery, jquery.ui
endif;
模板_b.php

// load jquery.js and jquery.ui.js
$("#dialog_a").load("template_a.php").dialog();
$("#dialog_b").load("template_b.php").dialog();
just HTML, no JS
// !!! -> load jquery.js and jquery.ui.js <- !!!
$("#dialog").load("template_c.php").dialog({modal:true});
$(".anchor_in_dialog_or_not_doesnt_matter").live("click", function() {
    $("#dialog").dialog();
});
if ($_GET["standalone"])
    // load jquery, jquery.ui
endif;
我希望它能帮助别人


编辑:正如下面已经提到的adamb,使用on()而不是live()

如果主页上已经有jQuery和jQueryUI,请不要再加载它们。从模板中取出它。php@adamb我不得不谷歌,但现在我知道这个社区是如何运作的。谢谢你的建议!。live()已被弃用。改为使用.on()@谢谢你的建议!