Bootstrap- Modal对话框如何在关闭时触发事件

  •  下表列出了模态框中要用到事件。这些事件可在函数中当钩子使用。 事件 描述 实例
    show.bs.modal 在调用 show 方法后触发。
    $('#identifier').on('show.bs.modal', function () { // 执行一些动作... })
    shown.bs.modal 当模态框对用户可见时触发(将等待 CSS 过渡效果完成)。
    $('#identifier').on('shown.bs.modal', function () { // 执行一些动作... })
    hide.bs.modal 当调用 hide 实例方法时触发。
    $('#identifier').on('hide.bs.modal', function () { // 执行一些动作... })
    hidden.bs.modal 当模态框完全对用户隐藏时触发。
    $('#identifier').on('hidden.bs.modal', function () { // 执行一些动作... })

    实例

     

  • //二级模式框关闭后导致模式框不能滚动的解决方法
    $(function () {
          $(".modal").on("hidden.bs.modal", function () {
            $(".modal").each(function () {
              if (this.style.display == 'block') {
                $("#body").addClass("modal-open");
              }
            })
          })
        })
     

猜你喜欢

转载自chendaiming.iteye.com/blog/2282881