如何关闭 jQuery Simplemodal?

发布于 2024-07-23 07:59:48 字数 176 浏览 0 评论 0原文

我想使用 ASP.Net MVC 从 JavaScript 函数关闭 Simplemodal 窗口,该函数在提交表单并接收结果 (AJAX) 后自动调用。 如何关闭 jQuery Simplemodal?

我是这样打开的:

$("#popup").modal()

I want to close a Simplemodal window from a JavaScript function that gets called automatically after a form is submitted and the results recived (AJAX), using ASP.Net MVC. How do I close a jQuery Simplemodal?

I've opened it this way:

$("#popup").modal()

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

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

发布评论

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

评论(4

话少情深 2024-07-30 07:59:48

您有 2 个选项:

1) 将 close 类 (simplemodal-close) 放在模态数据中的元素上,SimpleModal 会自动将 close 函数绑定到该元素上的单击事件。

以上面的示例为例,您需要:

<div id="foo" style="display:none">
  <p>Form HTML</p>
  <span class="simplemodal-close">Close</span>
</div>

2) 当您想以编程方式关闭对话框时,请调用:

$.modal.close();

HTH!

-Eric(SimpleModal 作者)

You have 2 options:

1) Put the close class (simplemodal-close) on an element in your modal data and SimpleModal will automatically bind the close function to the click event on that element.

Taking the example above, you'd want:

<div id="foo" style="display:none">
  <p>Form HTML</p>
  <span class="simplemodal-close">Close</span>
</div>

2) When you want to close the dialog programatically, call:

$.modal.close();

HTH!

-Eric (SimpleModal author)

苍景流年 2024-07-30 07:59:48

只需调用关闭即可。

$("#popup").close();

如果您是为了 ajax 完成而执行此操作,则需要添加回调。 您可能想检查是否失败。

var foo = $("#popup").modal();

$.ajax({url:url, success:function(){
    foo.close();
}});

Just call close.

$("#popup").close();

If you're doing it for an ajax completion you need to add a callback. You may want to check for failure.

var foo = $("#popup").modal();

$.ajax({url:url, success:function(){
    foo.close();
}});
怪我鬧 2024-07-30 07:59:48

如果以上解决方案都不起作用,您还可以尝试触发关闭按钮的点击事件(只要将其放置在弹出元素内部即可)。

$( ".simplemodal-close" ).trigger( "click" );

或者失败的话,使用 Javascript。

document.getElementById('closeModalButton').click();

If none of the above solutions work, you can also try to trigger the click event of the close button (so long as it is placed inside the popup element).

$( ".simplemodal-close" ).trigger( "click" );

or failing that, with Javascript.

document.getElementById('closeModalButton').click();
痞味浪人 2024-07-30 07:59:48
$.modal.close();

或者你可以使用以下命令

setTimeout('goto_previous_page()', 1000);
$.modal.close();

or you can use following command

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