首先,我用这个打开我的模态:
$('#myModal').modal('show');
Run Code Online (Sandbox Code Playgroud)
然后,在另一种情况下,我需要在按ESC /点击外面时这个相同的模态不会关闭,所以我使用这个:
$('#myModal').modal({
backdrop: 'static',
keyboard: false
})
Run Code Online (Sandbox Code Playgroud)
但是一旦我用第一种方法打开我的模态,第二种方法就不起作用了.任何提示?
如何强制backdrop值切换工作?
我正在使用Twitter Bootstrap来创建一个无法关闭的模态.这是故意的.但是,十秒钟后,我希望用户能够通过按下转义键或单击它外部来关闭模态.可以这样做吗?这是示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-header">
<h3 id="myModalLabel">A Modal That Can't Be Closed</h3>
</div>
<div class="modal-body">
<p>There is no way to close this modal. I would like to make it so that after ten seconds, pressing the escape key or clicking outside …Run Code Online (Sandbox Code Playgroud)