1

我的应用程序中有一个模式对话框,效果非常好。我使用以下功能设置并打开对话框

$(document).ready(function () {
    $("#__gsl_DialogPanel").dialog({
        autoOpen: false,
        resizable: false,
        position: 'center',
        stack: true,
        height: 'auto',
        width: 'auto',
        modal: true
    });
});

function loadDialog(action, id, title, onCloseHandler) {
    $("#__gsl_DialogPanel").dialog("option", "title", title);
    var url = action;
    if (id != "") url = url + "/" + id;
    $.ajax({
        type: "get",
        dataType: "html",
        url: url,
        data: {},
        success: function(response) {
            $("#__gsl_DialogPanel").html('').html(response).dialog('open');
        }
    });
}

现在我需要从前一个对话框中的按钮打开另一个对话框。我创建了另一个 div(“__gsl_DialogPanel_2L”)并克隆了引用新对话框的 setup 和 open 函数,如下面的代码

$("__gsl_DialogPanel_2L").dialog({
    autoOpen: false,
    resizable: false,
    position: 'center',
    stack: true,
    height: 'auto',
    width: 'auto',
    modal: true
});

function loadDialog2L(action, id, title, onCloseHandler) {
    $("#__gsl_DialogPanel_2L").dialog("option", "title", title);
    var url = action;
    if (id != "") url = url + "/" + id;
    $.ajax({
        type: "get",
        dataType: "html",
        url: url,
        data: {},
        success: function (response) {
            $("#__gsl_DialogPanel_2L").html('').html(response).dialog('open');
        }
    });
}

问题是第二个对话框根本没有打开。我检查了 Chrome 开发人员工具,我可以看到 div 包含从 ajax 调用接收到的正确 HTML,但其样式属性中仍有“显示:无”。

我在哪里做错了?

更新:

这些是使用的div。它们位于 BODY 标记之后的母版页中。

<!-- Generic Dialog Panel  -->
<div id="__gsl_DialogPanel" style="display:none" title=""></div>
<!-- 2 Level Dialog Panel  -->
<div id="__gsl_DialogPanel_2L" style="display:none" title=""></div>

第二次更新

我在JSBin创建了一个简化的示例。你可以在这里找到它。有什么帮助吗?

4

1 回答 1

0

通过将第二个 div id(和对它的引用)更改为“foo”,我能够让您在 jsbin 上的示例正常工作。我怀疑发生了某种名称冲突 - 也许在 Javascript 或 div id 的变量名称上存在最大数量的重要字符?(经过短暂搜索,我似乎无法在任何地方找到该说明)。

于 2010-10-13T17:07:13.467 回答