Reputation: 508
Suppose I have a modal for example
I want to trigger an event when this modal is closed. THe model get closed when we click on the close button or anywhere outside the close button
<a href='#part-3' data-toggle='modal' id='sss' style='float:right; color:black;' >view</a></center>
//code for modal
<div class="modal modal-wide fade" id="part-3" >
<div class="modal-dialog" style="min-width:60%">
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" >×</button>
</div>
<div class="modal-body">
<div class="show">
//the html code of form which is popped up
</div>
</div>
</div>
</div>
I can easily create an jquery event when closing the modal through close button by giving it an id but how to trigger/ what should be name of that trigger when user click anywhere outside the modal..
Upvotes: 3
Views: 10399
Reputation: 7715
In bootstrap, a javascript event already fires when a modal is closed/hidden:
$('#myModal').on('hide.bs.modal', function (e) {
// do something...
})
See the relevant documentation here for more events.
Upvotes: 11