禁用在引导模型区域外单击以关闭模态 [英] Disable click outside of bootstrap model area to close modal
问题描述
我在做一个引导网站,有几个Bootstrap'Modals'。
我试图自定义一些默认功能。
I am making a bootstrap website, with a couple of Bootstrap 'Modals'. I'm trying to customize some of the default features.
问题是这样的;
您可以通过点击背景关闭模态。
是否仍然禁用此功能?
仅适用于特定模式?
Problem is this; You can close the modal by clicking on the background. Is there anyway to disable this feature? On specifc modals only?
推荐答案
在选项章节的链接页面中,您可以看到 $ c>选项。将此选项与值
'static'
传递将阻止关闭模态。
由于@PedroVagner指向注释,您还可以传递 {keyboard:false}
,以防止按 Esc 关闭模态。
On Options chapter, in the page you linked, you can see the backdrop
option. Passing this option with value 'static'
will prevent closing the modal.
As @PedroVagner pointed on comments, you also can pass {keyboard: false}
to prevent closing the modal by pressing Esc.
如果您通过js打开模式,请使用:
If you opening the modal by js use:
$('#myModal').modal({backdrop: 'static', keyboard: false})
您正在使用数据属性,请使用:
If you are using data attributes, use:
<button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
Launch demo modal
</button>`
这篇关于禁用在引导模型区域外单击以关闭模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!