ID 更改时关闭模态框

发布于 2024-11-17 09:28:54 字数 417 浏览 1 评论 0原文

我正在使用 Eric Martin 的 SimpleModal (http://www.ericmmartin.com/projects/simplemodal-demos/),网址为 www.1tryten.com/checkout.php。加载代码很简单:

jQuery(function ($) {
$('#CheckoutStepAccountDetails').modal();

});

这将加载一个具有 2 个提交选项的表单,提交表单后,类 .ExpressCheckoutBlockCompleted 将添加到 div#CheckoutStepAccountDetails 中。这时候我需要让Modal消失。我尝试将 simplemodal-close 类添加到提交按钮,但随后它只是关闭模式而不提交表单。有谁知道我怎样才能做到这一点?

I'm using the SimpleModal by Eric Martin (http://www.ericmmartin.com/projects/simplemodal-demos/) at www.1tryten.com/checkout.php. The code for loading is simply:

jQuery(function ($) {
$('#CheckoutStepAccountDetails').modal();

});

This loads a form with 2 submit options, once the form has been submitted the class .ExpressCheckoutBlockCompleted is added to the div#CheckoutStepAccountDetails. At this time I need the Modal to disappear. I've tried adding the simplemodal-close class to the submit button, but then it simply closes the modal without submitting the form. Does anyone know how I could make this work?

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

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

发布评论

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

评论(2

亚希 2024-11-24 09:28:54

本,
我怀疑仅仅在你的 div 中添加一个类就会让你消失模式。

我不使用该插件,但我使用自己的自定义代码来实现我的简单模式。

这就是我控制何时以及如何控制模式关闭的方式:

//modal has a close button with id=modalclose. when it is clicked, I hide the modal mask
//this will close modal only if close button is clicked
$("#dialog #modalclose").click(function (e) { 
  $('#mask, .window').hide(); 
});

//if I want to close the modal by outside click on the mask
$("#mask").click(function (e) { 
  $('#mask, .window').hide(); 
});

因此,对于您的情况,您需要在提交表单后添加此类调用
如果提交表单时有可用的回调函数,则可以添加代码以隐藏该回调函数内的模式。

希望这有帮助。

Ben,
I doubdt that just adding a class to your div will let you disappear the modal.

I don't use that plugin but I use own custom code for my simple modal.

This is how I control when and how to control the modal to close:

//modal has a close button with id=modalclose. when it is clicked, I hide the modal mask
//this will close modal only if close button is clicked
$("#dialog #modalclose").click(function (e) { 
  $('#mask, .window').hide(); 
});

//if I want to close the modal by outside click on the mask
$("#mask").click(function (e) { 
  $('#mask, .window').hide(); 
});

So for your case you need to add this type of call once the form is submitted
If you have a callback function available upon the form is submitted, you can add the code to hide the modal inside that call back function.

Hope this helps.

悸初 2024-11-24 09:28:54

为了澄清,与 Projapati 所说的相反,向模态内的元素添加一个 simplemodal-close 类实际上会导致对话框在单击时关闭。

根据您提供的内容,您需要做的就是以下内容:

//if I want to close the modal by outside click on the mask
$("#mask").click(function (e) { 
  $.modal.close(); 
});

抱歉,我无法早些时候回复此问题,我正在度假;)

For clarification, contrary to what Projapati said, adding a class of simplemodal-close to an element inside the modal will, in fact, cause the dialog to close when clicked.

Based on what you've provided, all you should need to do is the following:

//if I want to close the modal by outside click on the mask
$("#mask").click(function (e) { 
  $.modal.close(); 
});

Sorry I wasn't able to respond to this earlier, I was on vacation ;)

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