SimpleModal - 调用“modal()”在同一个元素上
我有一个页面,我想在其中包含几个由 SimpleModal 实现的模态窗口实例。具体场景如下:
- 页面已加载。
- 用户点击按钮打开模式窗口。
- 在模式中,用户插入(输入)他需要的所有信息。
- 数据经过验证。 如果验证失败,则应显示一个新的模式并显示错误。这个概念是有一个模态窗口,它应该像 javascriptalert() 函数一样工作。
- 当错误可见时,之前的模态窗口应该消失。一旦用户单击“确定”,错误应该消失并且旧的模态窗口应该出现。
现在,我正在寻找答案,并且看到了 Eric Martin(SimpleModal 的开发人员)的几篇帖子,讨论了如何拥有多个模式窗口。 SimpleModal 似乎不支持它,他建议的是用新的内容替换模式的内容。
我想做的是:
- 在显示警报之前,我保留打开模式的 ID。
- 隐藏所有打开的模态(隐藏 div)。
- 显示警报并绑定“确定”按钮。
- 当用户单击“确定”时,我关闭(警报的)当前模式,获取旧 div 的名称,然后通过调用 ShowDialog("getSubsidiariesForCustomer") 再次显示它。
我的问题是,当我尝试运行最后一个命令时,它不起作用。经过调查后,如果在某个元素上调用了 modal() 函数,SimpleModal 插件的实现似乎会保留一个标志。
只是为了一般知识:
- 我正在使用简单的模态 1.41
看起来我在 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:
- The page is loaded.
- The user hits a button to open a modal window.
- In the modal, the user inserts (inputs) all the information he is required.
- 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.
- 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:
- Before I show the alert, I keep the ID of the open modal.
- Hide all the open modals (hide the divs).
- Show the alert and bind the OK button.
- 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:
- I'm using simple modal 1.41
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的问题 (#4) 可能与我在 SimpleModal 中处理 Opera 问题的
setTimeout
代码有关。我需要删除它,但现在您可以尝试通过查找以下内容来编辑 SimpleModal 源:并将其替换为:
如果这对您不起作用,请告诉我...
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:And replacing it with:
Let me know if that does not work for you...