当我有一个引导模式时,我想捕获导致它关闭的按钮类型。
<div id="fooModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel4" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel4">List</h3>
</div>
<div class="modal-body">
... whatever ...
</div>
<div class="modal-footer">
<button class='btn' data-dismiss='modal' aria-hidden='true'>Action 1</button>
<button class='btn btn-primary' aria-hidden='true'>Action 2</button>
<button class='btn' aria-hidden='true'>Action 3</button>
</div>
</div>
并在脚本中
$("#fooModal")
.modal({backdrop:'static'})
.on('hidden', function (event) {
console.log("foo hidden", event); // can't see the button, only the modal div itself
// candidates for what "closed" the modal:
// "x" button
// "Action 1"
// "Action 2"
// "Action 3"
})
.modal('show');
是否有对导致模式关闭的按钮的引用?