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/