禁用在引导模式区域之外单击以关闭模式
我正在制作一个引导网站,其中包含几个引导模式".我正在尝试自定义一些默认功能.
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?
引导模式页面
推荐答案
在选项章节,在你链接的页面中,你可以看到backdrop
选项.使用值 '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>`
相关文章