关闭Bootstrap模式 [英] Close Bootstrap Modal

查看:107
本文介绍了关闭Bootstrap模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个最初要显示的引导模式对话框,然后当用户单击页面时,该对话框消失.我有以下内容:

I have a bootstrap modal dialog box that I want to show initially, then when the user clicks on the page, it disappears. I have the following:

$(function () {
   $('#modal').modal(toggle)
});

 <div class="modal" id='modal'>
     <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Error:</h3>
        </div>
        <div class="modal-body">
        <p>Please correct the following errors:</p>
        </div>
     </div>
 </div>

模态最初显示,但是在模态外部单击时它不会关闭.此外,内容区域不会显示为灰色..如何使模式最初显示,然后在用户在区域之外单击后关闭?以及如何像演示中一样使背景变灰呢?

The modal is displayed initially, but it does not close when clicked outside of the modal. Also, the content area is not greyed out.. How can I get the modal to display initially, then close after the user clicks outside the area? And how can I get the background to be grayed out as in the demo?

推荐答案

放入modal('toggle')而不是modal(toggle)

$(function () {
   $('#modal').modal('toggle');
});

这篇关于关闭Bootstrap模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆