jquery - 如何在 Bootstrap 模式关闭时触发事件

标签 jquery twitter-bootstrap

假设我有一个模式 enter image description here

我想在关闭此模式时触发一个事件。当我们点击关闭按钮或关闭按钮之外的任何地方时,模型就会关闭

    <a href='#part-3' data-toggle='modal' id='sss' style='float:right; color:black;' >view</a></center>

 //code for modal

  <div class="modal modal-wide fade" id="part-3" >
<div class="modal-dialog" style="min-width:60%">
  <div class="modal-content" >
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" >&times;</button>

    </div>
    <div class="modal-body">
        <div class="show">
           //the html code of form which is popped up
        </div>
    </div>
  </div>
</div>

当通过关闭按钮关闭模态时,我可以轻松地创建一个jquery事件,方法是给它一个id,但是当用户单击模态之外的任何地方时如何触发/该触发器的名称应该是什么..

最佳答案

在 Bootstrap 中,当模式关闭/隐藏时,JavaScript 事件已经触发:

$('#myModal').on('hide.bs.modal', function (e) {
  // do something...
})

查看相关documentation here了解更多事件。

关于jquery - 如何在 Bootstrap 模式关闭时触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32383070/

相关文章:

javascript - jQuery addClass 到子元素

jquery - 如何在li上显示隐藏的div :hover?

javascript - 如何使用 JQuery DatePicker 返回 YYYYMMDD 格式的日期?

蓝色边框后的 CSS (bootstrap) 行(附示例)

twitter-bootstrap - Bootstrap 3 - 为什么行类比其容器宽?

javascript - JQuery 隐藏和取消隐藏下拉选择器中的元素

javascript - 重定向弹出页面并显示进度

javascript - 显示方法上的 Bootstrap 模式多次运行

javascript - 无法将 ui.bootstrap 注入(inject)我的模块

html - Bootstrap 对齐按钮底部的 div