【发布时间】:2017-07-02 22:45:21
【问题描述】:
我希望我的引导模式打开,但后台页面仍然可以点击。
我尝试了网络和 stackoverflow(如 How do I make the background of a modal clickable)上的一些解决方案,但我无法让它工作。我正在使用 Firefox 和 IE11。
我尝试实现的目标:在页面侧面有一个按钮,用于打开模式,处理模型内容,通过单击标题中的按钮关闭模式或使用点击打开模式的按钮。
有一个working Bootply example,我尝试从中改编一些东西,但到目前为止没有多大成功。
这是我已经走了多远:
模态
(下面的 html 是用 javascript 生成的,我只是给你输出以提高可读性)
<div id="bootstrapModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success " id="submitButton">Submit</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" >Cancel</button>
</div>
</div>
</div>
</div>
Javascript
var modal = $('#bootstrapModal');
$('.modal-backdrop', modal).css('display', 'none');
$('.modal-dialog',modal).css('pointer-events', 'none');
$('.modal-content',modal).css('pointer-events', 'all',);
$(modal).modal('show');
我得到的是一个没有背景但可以与背景交互的模态(背景看起来是活动的,但不是)。我用
得到同样的效果$(modal).modal({backdrop: 'static', keyboard: false});
或者在将backdrop 中的'static' 替换为false 时。
有什么想法吗?
【问题讨论】:
标签: javascript jquery html css twitter-bootstrap