如何关闭 jQuery Simplemodal?
我想使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您有 2 个选项:
1) 将 close 类 (simplemodal-close) 放在模态数据中的元素上,SimpleModal 会自动将 close 函数绑定到该元素上的单击事件。
以上面的示例为例,您需要:
2) 当您想以编程方式关闭对话框时,请调用:
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:
2) When you want to close the dialog programatically, call:
HTH!
-Eric (SimpleModal author)
只需调用关闭即可。
如果您是为了 ajax 完成而执行此操作,则需要添加回调。 您可能想检查是否失败。
Just call close.
If you're doing it for an ajax completion you need to add a callback. You may want to check for failure.
如果以上解决方案都不起作用,您还可以尝试触发关闭按钮的点击事件(只要将其放置在弹出元素内部即可)。
或者失败的话,使用 Javascript。
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).
or failing that, with Javascript.
或者你可以使用以下命令
or you can use following command