本文介绍了显示模态时不会触发Twitter Bootstrap模态事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据文档:
http://getbootstrap.com/javascript/#modals
它应该触发方法"show.bs.dropdown"和"shown.bs.dropdown".但这不是:
It should fire the methods "show.bs.dropdown" and "shown.bs.dropdown". But it doesn't:
HTML:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">Hello world</div>
</div>
</div>
jQuery:
// show.bs.modal doesn't work either
$('#myModal')
.modal('show')
.on('show.bs.modal', function() {
alert('shown baby!');
});
推荐答案
您需要先注册事件然后触发它
Youe need first register event then trigger it
$('#myModal')
.on('show.bs.modal', function() {
alert('shown baby!');
}).modal('show');
这篇关于显示模态时不会触发Twitter Bootstrap模态事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!