Bootstrap 3: 监听弹出窗口关闭/打开事件 How to handle the modal closing event in Twitter Bootstrap?

Updated for Bootstrap 3

Bootstrap 3 documentation refers two events you can use

hide.bs.modal: This event is fired immediately when the hide instance method has been called.
hidden.bs.modal: This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).

And provides an example on how to use them:

$('#myModal').on('hidden.bs.modal', function () {
  // do something…
})
$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})

Legacy Bootstrap 2.3.2 answer

Bootstrap’s documentation refers two events you can use

hide: This event is fired immediately when the hide instance method has been called.
hidden: This event is fired when the modal has finished being hidden from the user (will wait for css transitions to complete).

And provides an example on how to use them:

$('#myModal').on('hidden', function () {
    // do something…
})
$('#myModal').on('show', function (e) {
    if (!data) return e.preventDefault() // stops modal from being shown
})

参考:http://stackoverflow.com/a/12319710/602382

更多参考:

Bootstrap 3: 菜单居中 Center content in responsive bootstrap navbar2016-08-08

Bootstrap 3 : 实现5栏设计 5 columns layout with Twitter Bootstrap

Bootstrap 3 添加外部页面到弹出窗口Bootstrap 3 with remote Modal

Bootstrap 3: 无限级别下拉菜单 Multi level dropdown menu in Bootstrap 3

Bootstrap 3 关闭Modal窗口 Close Bootstrap Modal

 

 

本文:Bootstrap 3: 监听弹出窗口关闭/打开事件 How to handle the modal closing event in Twitter Bootstrap?

 

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.