Disallow Twitter Bootstrap modal window from closing
I am creating a modal window using Twitter Bootstrap. The default behavior is if you click outside the modal area, the modal will automatically close. I would like to disable that -- ie not close the modal window when clicking outside the modal.
Can someone share jQuery code to do this?
I believe you want to set the backdrop value to static . If you want to avoid the window to close when using the Esc key, you have to set another value.
Example:
<a data-controls-modal="your_div_id"
data-backdrop="static"
data-keyboard="false"
href="#">
OR if you are using JavaScript:
$('#myModal').modal({
backdrop: 'static',
keyboard: false
});
Just set the backdrop
property to 'static'
.
$('#myModal').modal({
backdrop: 'static',
keyboard: true
})
You may also want to set the keyboard
property to false
because that prevents the modal from being closed by pressing the Esc key on the keyboard.
$('#myModal').modal({
backdrop: 'static',
keyboard: false
})
myModal
is the ID of the div that contains your modal content.
您也可以在模态定义本身中包含这些属性:
<div class="modal hide fade" data-keyboard="false" data-backdrop="static">
链接地址: http://www.djcxy.com/p/83684.html