Disable click outside of bootstrap modal area to close modal(禁用在引导模式区域之外单击以关闭模式)
问题描述
我正在制作一个引导网站,其中包含几个引导模式".我正在尝试自定义一些默认功能.
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>`
这篇关于禁用在引导模式区域之外单击以关闭模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁用在引导模式区域之外单击以关闭模式


- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01