I am using Twitter's Bootstrap modal.
我正在使用Twitter的Bootstrap模式。
The modal is dismissed whenever the user clicks anywhere else on the screen except the modal.
只要用户点击屏幕上除模式之外的任何其他位置,模态就会被取消。
Is there a way I can prevent this, so the user has to click the Close button to dismiss the modal?
有没有办法可以防止这种情况,所以用户必须单击关闭按钮才能解除模态?
Best,
最好,
3 个解决方案
#1
52
you can pass these options:
你可以传递这些选项:
{
keyboard: false,
backdrop: 'static'
}
#2
43
In most cases, the modal dialog is constructed not using Javascript, rather it's using the markup, in this scenario, just add attribute: data-backdrop="static" in the div that has class="modal fade".
在大多数情况下,模态对话框不是使用Javascript构建的,而是使用标记,在这种情况下,只需在具有class =“modal fade”的div中添加属性:data-backdrop =“static”。
Example:
例:
<div class="modal fade" id="myModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
#3
4
In some cases, this alternative solution may be useful.
在某些情况下,这种替代解决方案可能是有用的。
$('#modalElement').on('hide.bs.modal', function () {
return false;
});
#1
52
you can pass these options:
你可以传递这些选项:
{
keyboard: false,
backdrop: 'static'
}
#2
43
In most cases, the modal dialog is constructed not using Javascript, rather it's using the markup, in this scenario, just add attribute: data-backdrop="static" in the div that has class="modal fade".
在大多数情况下,模态对话框不是使用Javascript构建的,而是使用标记,在这种情况下,只需在具有class =“modal fade”的div中添加属性:data-backdrop =“static”。
Example:
例:
<div class="modal fade" id="myModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
#3
4
In some cases, this alternative solution may be useful.
在某些情况下,这种替代解决方案可能是有用的。
$('#modalElement').on('hide.bs.modal', function () {
return false;
});