禁用在引导模式区域之外单击以关闭模式 [英] Disable click outside of bootstrap modal area to close modal

查看:26
本文介绍了禁用在引导模式区域之外单击以关闭模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个引导网站,其中包含几个引导模式".我正在尝试自定义一些默认功能.

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>`

这篇关于禁用在引导模式区域之外单击以关闭模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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