javascript - “hidden.bs.modal”延迟触发?

标签 javascript jquery twitter-bootstrap

var switchProductDetailsToCartModal = function (target){
    $('#productDetailsModal').modal('hide'); // 'hidden.bs.modal' was not triggered here

    $('#carousel-example-generic').carousel('pause');
    // 
}

//'hidden.bs.modal' handler triggered here and carousel steel cycling


$(function() {
    $('#productDetailsModal').on('hidden.bs.modal', function (){
        $('#carousel-example-generic').carousel('cycle');
    });
});

这是正常行为吗?无论如何,如何在 modal('hide') 之后立即触发 'hidden.bs.modal' 处理程序?

jquery-1.11.3, Bootstrap 3

最佳答案

您需要使用不同的事件,hide.bs.modal。这将在调用 hide 后立即触发:

$('#productDetailsModal').on('hide.bs.modal', function (){
  $('#carousel-example-generic').carousel('cycle');
});

来自 Bootstrap docs :

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).

关于javascript - “hidden.bs.modal”延迟触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30918325/

相关文章:

javascript - 用户缩放或右键单击重置时的谷歌图表事件

html - Bootstrap 中的垂直对齐

jquery - Bootstrap 4 导航栏无法在 IE11 中正确呈现

javascript - 如何生成测试广告以检查广告的 div 宽度是否足够?

javascript - 在 JS 中设置没有单位的 CSS 值

javascript - 仅在表单提交时导航至页面

javascript - react 响应式导航栏

javascript - 带有实时数据的传单弹出窗口

javascript - 只要使用 JavaScript 的项目尚不存在于数组中,就推送到数组

jQuery Datepicker - 自动为所有日期选择器定义 altField