Twitter bootstrap 引导3模式在外部单击时不关闭
我已经用call创建了一个模态Twitter bootstrap 引导3模式在外部单击时不关闭,twitter-bootstrap,Twitter Bootstrap,我已经用call创建了一个模态 $('#myModalContent').modal('show'); html是: <div class=" modal fade" id="myModalContent" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class=
$('#myModalContent').modal('show');
html是:
<div class=" modal fade" id="myModalContent" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
&时代;
问题是当我在模式弹出窗口外单击时,它不会关闭。(esc关闭)您可以通过以下方式将选项传递给模式:
$('#myModal').modal({
show:true,
backdrop:true,
keyboard:true
})
我已经编写了自定义代码来解决这个问题
$("body").on("click", ".modal-dialog", function(e) {
if ($(e.target).hasClass('modal-dialog')) {
var hidePopup = $(e.target.parentElement).attr('id');
$('#' + hidePopup).modal('hide');
}
});
如果您使用的是bootstrap3,它应该可以工作
&时代;
小模态
...
并将其命名为:$('#modalExample').modal() 只需将
data background=“static”
和data keyboard=“false”
属性添加到该模式中(即您有class='modal'
)
data background=“true”
是允许后台单击解雇的默认行为,data background=“static”
是您解释的行为,没有解雇,因此您可能已将其设置为“static”
data keyboard=“false”
用于不允许ESC您使用哪个版本的引导?它不适用于bootstrap 2.1,但适用于v2.3和v3:您是否尝试将data background=“true”
添加到class='modal'
div中?True是允许后台单击解雇的默认行为,data background=“static”
是您解释的行为,无解雇与angularjs无关,因此您可以删除angularjstag@Getz,我使用的是3.1.1…@Siddesh Bhalke,所以请尝试提供一个复制您的问题的提琴。
It should work if you are using bootstrap 3
<div class="modal fade bs-example-modal-sm" id="modalExample" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 class="modal-title">Small Modal</h4>
</div>
<div class="modal-body">...</div>
</div>
</div>
</div>
//remove modal class from modal start div and
$('#MyModal').modal({ backdrop: false });
$('body').removeClass("modal-open");