堆叠式 jQuery UI 对话框

发布于 2024-09-27 08:23:46 字数 2088 浏览 4 评论 0原文

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

$(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") 并克隆了引用新对话框的设置和打开函数,如以下代码所示。

$("__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,但其 style 属性中仍然有“display: none”。

我哪里做错了?

更新:

这些是使用的 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 上创建了一个简化的示例。您可以在此处找到它。有什么帮助吗?

I have one modal dialog in my application that works very nice. I do setup and open of the dialog with the following functions

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

Now I have the requirement to open another dialog from a button that's inside the previous dialog. I have created another div ("__gsl_DialogPanel_2L") and cloned the setup and open function referring to the new dialog as in the following code

$("__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');
        }
    });
}

The problem is that the second dialog does not open at all. I have checked with Chrome Developer tools and I can see that the div contains the right HTML that has been received from the ajax call but still has "display: none" in its style property.

Where I am doing wrong?

Update:

These are the div's used. They are in the master page immediately after the BODY tag.

<!-- 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>

2nd Update:

I have created a simplified sample on JSBin. You can find it here. Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-10-04 08:23:46

通过将第二个 div id(及其引用)更改为“foo”,我能够让您在 jsbin 上的示例正常工作。我怀疑发生了某种名称冲突——也许 Javascript 或 div id 中的变量名称上存在最大数量的有效字符? (简单搜索了一下,但我似乎找不到任何地方的说明)。

I was able to get your example on jsbin to work by changing the second div id (and references to it) to "foo". I suspect there is some kind of name collision occurring -- perhaps there is a maximum number of significant characters on the variable name in Javascript or the div id's? (Searched briefly and I can't seem to find that stated anywhere, however).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文