Leo Loki Leo Loki - 5 months ago 26
jQuery Question

How to add an event after close the modal window?

I have code modal:

<-- Button to trigger modal -->
<div id="result"></div>
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<-- Modal -->
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>


And i have code when should been after close moal window:

$('#result').html('yes,result');


Tell me please how to make that when closing the modal window(close or hide) executed a second code ?

Answer

I find answer. Thanks all but right answer next:

$("#myModal").on("hidden.bs.modal", function () {
$('#result').html('yes,result');
});

Events here http://bootstrap-ru.com/javascript.php#modals