I'm facing an issue with a modal, I have one and when I close it I need running something, actually when it closes, I need refresh the index.php.
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min_2.1.4.js"></script>
<script src="js/bootstrap3.3.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" />
<script>
$('#myModal').modal({
'show': false
});
$('#btnModal').click(function() {
$('#myModal').modal('show');
});
$('#myModal').on('hide', function(e) {
if (!confirm('You want to close me?'))
e.preventDefault();
});
</script>
</head>
<body><!-- Button trigger modal -->
<button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<a role="button" class="btn" id="btnModal">Launch demo modal</a>
<!-- Modal -->
<div id="myModal" class="modal hide fade" 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>
</body>
</html>
I have this example, and I can't do it works. Someone could help me? Thks
Bootstrap have it's own shown & hidden event names:
on('shown.bs.modal',function() { ... })
on('hidden.bs.modal',function() { ... })
Hope this help. Good luck!
UPDATE: More bootstrap's modal event names:
show.bs.modal
: Occurs when the modal is about to be shownshown.bs.modal
: Occurs when the modal is fully shown (after CSS transitions have completed)hide.bs.modal
: Occurs when the modal is about to be hiddenhidden.bs.modal
: Occurs when the modal is fully hidden (after CSS transitions have completed)
See the Bootstrap docs for further reference: http://getbootstrap.com/javascript/#modals-events