如何在关闭Bootstrap 3模式时重新加载页面 [英] How to reload page on closing a Bootstrap 3 modal
本文介绍了如何在关闭Bootstrap 3模式时重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目标是在Bootstrap模式关闭时重新加载页面。用户可以通过单击关闭按钮或图标或单击远离模态来关闭模态。
My aim is to get the page to reload when a Bootstrap modal is closed. The user can close the modal by clicking on the close button or icon or by clicking away from the modal.
到目前为止,我的代码非常标准。取自:
http://getbootstrap.com/javascript/#modals
My code so far is pretty standard. Taken from: http://getbootstrap.com/javascript/#modals
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">My title</h4>
</div>
<div class="modal-body">
My content
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
如何在模式关闭后重新加载页面?
How can I get the page to reload after a modal is closed?
更新:哇,来自每个人的惊人快速反应。谢谢
Update: Wow, fantastic fast response from everybody. Thank you
推荐答案
您可以点击关闭时将事件绑定到重新加载页面:
You can bind the event to reload page on click of close:
$('#myModal').on('hidden.bs.modal', function () {
location.reload();
})
Demo
这篇关于如何在关闭Bootstrap 3模式时重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文