SimpleModal - 调用“modal()”在同一个元素上

发布于 2024-10-26 05:03:23 字数 2354 浏览 2 评论 0原文

我有一个页面,我想在其中包含几个由 SimpleModal 实现的模态窗口实例。具体场景如下:

  1. 页面已加载。
  2. 用户点击按钮打开模式窗口。
  3. 在模式中,用户插入(输入)他需要的所有信息。
  4. 数据经过验证。 如果验证失败,则应显示一个新的模式并显示错误。这个概念是有一个模态窗口,它应该像 javascriptalert() 函数一样工作。
  5. 当错误可见时,之前的模态窗口应该消失。一旦用户单击“确定”,错误应该消失并且旧的模态窗口应该出现。

现在,我正在寻找答案,并且看到了 Eric Martin(SimpleModal 的开发人员)的几篇帖子,讨论了如何拥有多个模式窗口。 SimpleModal 似乎不支持它,他建议的是用新的内容替换模式的内容。

我想做的是:

  1. 在显示警报之前,我保留打开模式的 ID。
  2. 隐藏所有打开的模态(隐藏 div)。
  3. 显示警报并绑定“确定”按钮。
  4. 当用户单击“确定”时,我关闭(警报的)当前模式,获取旧 div 的名称,然后通过调用 ShowDialog("getSubsidiariesForCustomer") 再次显示它。

我的问题是,当我尝试运行最后一个命令时,它不起作用。经过调查后,如果在某个元素上调用了 modal() 函数,SimpleModal 插件的实现似乎会保留一个标志。

只是为了一般知识:

  1. 我正在使用简单的模态 1.41
  2. 看起来我在 JS 的第 216 行上失败了:

    //不允许多次调用 如果(SD数据){ 返回假; 看起来

就在本节之后: 我首先运行“jBtnNew_Click”的逻辑:

Admin.BL.SettingsPage.jBtnNew_Click=function(e)
{
    Admin.BL.EcmSettings.ShowDialog("#getSubsidiariesForCustomer");
    alert(""); //Just for debugging
    Admin.BL.EcmSettings.ShowAlert();
}

Admin.BL.SettingsPage.ShowAlert=function()
{
    var id = $("div.model:visible").eq(0).attr("id");
    $("#alertBtnOk").one("click", function(e){
        $.modal.close();
        if (id != undefined)
        {
            Admin.BL.SettingsPage.ShowDialog(id);
        }
    }
    );
    Admin.BL.SettingsPage.ShowDialog("#alert");
}

Admin.BL.SettingsPage.ShowDialog=function(dialogId)
{
    if (dialogId.indexOf("#") < 0)
    {
        dialogId = "#" + dialogId;
    }
    $("div.model").hide();
    $("#dialog").modal({position:new Array("20%"),
    overlayId:"dialog-overlay",
    containerId:"confirm-container"});
    $(dialogId).show();
}

这是我的 HTML:

获取客户的子公司 客户编号: 客户姓名: 这是我的警报

任何有关解决此问题的帮助将不胜感激!!

谢谢:)

I have one page which I want to have in it few instances of modal windows implemented by SimpleModal. The exact scenario is as follows:

  1. The page is loaded.
  2. The user hits a button to open a modal window.
  3. In the modal, the user inserts (inputs) all the information he is required.
  4. The data is validated. If the validation is failed, a new modal should show up with the error. The concept is to have a modal window that should work just like javascript alert() function.
  5. When the error is visible, the previous modal should disappear.Once the user clicks on OK the error should go away and the old modal should come up.

Now, I've searched for an answer and I saw several posts of Eric Martin (the developer of SimpleModal) talking about having multiple modal windows. It seems like that SimpleModal doesn't support it, and what he recommends is the to replace the content of the modal with the new one.

What I'm trying to do is:

  1. Before I show the alert, I keep the ID of the open modal.
  2. Hide all the open modals (hide the divs).
  3. Show the alert and bind the OK button.
  4. When the user clicks OK, I close the current modal (of the alert), get the name of the old div, and show it again by calling ShowDialog("getSubsidiariesForCustomer").

My problem is that when I try to run the last command it doesn't works. After investigating it seems like that the implementation of the SimpleModal plugin is keeping a flag if the modal() function was called on the certain element.

Just for general knowledge:

  1. I'm using simple modal 1.41
  2. It seems like I'm faling on line 216 in the JS:

    // don't allow multiple calls
    if (s.d.data) {
    return false;
    }

My code is the just after this section:
I'm starting by running the logic of "jBtnNew_Click":

Admin.BL.SettingsPage.jBtnNew_Click=function(e)
{
    Admin.BL.EcmSettings.ShowDialog("#getSubsidiariesForCustomer");
    alert(""); //Just for debugging
    Admin.BL.EcmSettings.ShowAlert();
}

Admin.BL.SettingsPage.ShowAlert=function()
{
    var id = $("div.model:visible").eq(0).attr("id");
    $("#alertBtnOk").one("click", function(e){
        $.modal.close();
        if (id != undefined)
        {
            Admin.BL.SettingsPage.ShowDialog(id);
        }
    }
    );
    Admin.BL.SettingsPage.ShowDialog("#alert");
}

Admin.BL.SettingsPage.ShowDialog=function(dialogId)
{
    if (dialogId.indexOf("#") < 0)
    {
        dialogId = "#" + dialogId;
    }
    $("div.model").hide();
    $("#dialog").modal({position:new Array("20%"),
    overlayId:"dialog-overlay",
    containerId:"confirm-container"});
    $(dialogId).show();
}

And this is my HTML:

Get Customer's Subsidiaries

Customer ID:

Customer Name:

This is my alert

Any help on solving this issue will be appreciated!!

Thanks :)

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

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

发布评论

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

评论(1

一百个冬季 2024-11-02 05:03:23

我认为您的问题 (#4) 可能与我在 SimpleModal 中处理 Opera 问题的 setTimeout 代码有关。我需要删除它,但现在您可以尝试通过查找以下内容来编辑 SimpleModal 源:

setTimeout(function(){
    // opera work-around
    s.d.overlay.remove();

    // reset the dialog object
    s.d = {};
}, 10);

并将其替换为:

s.d.overlay.remove();
// reset the dialog object
s.d = {};

如果这对您不起作用,请告诉我...

I think your issue (#4) may be with the setTimeout code I have in SimpleModal to deal with Opera issues. I need to remove it, but for now you can try editing the SimpleModal source by finding the following:

setTimeout(function(){
    // opera work-around
    s.d.overlay.remove();

    // reset the dialog object
    s.d = {};
}, 10);

And replacing it with:

s.d.overlay.remove();
// reset the dialog object
s.d = {};

Let me know if that does not work for you...

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