简体   繁体   English

您可以在引导程序模态上使用“ x”(关闭)按钮来调用javascript函数而不是关闭模态吗?

[英]Can you get the 'x' (close) button on a bootstrap modal to call a javascript function instead of closing the modal?

I'm implementing a bootstrap modal and need to change the functionality of the 'close' button (the small x in the upper right corner). 我正在实现自举程序模式,需要更改“关闭”按钮的功能(右上角的小x)。 I want that to call a javascript function instead of closing the modal . 我希望调用javascript函数而不是关闭modal This is for a research project and not a production web site (I realize this would likely always be a bad idea on a live site). 这是针对研究项目的,而不是针对生产网站的(我意识到,在实时站点上,这可能总是一个坏主意)。

Yeah, you just have to use the modal's 'hide' event. 是的,您只需要使用模式的“隐藏”事件。 See the docs. 参见文档。

$("#exampleModal").on("hide.bs.modal", function(event){
        event.preventDefault();
          //do whatever here
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM