Prevent Bootstrap Modal from disappearing when cli

2020-01-25 02:54发布

I'm using the Twitter Bootstrap modal as a wizard window, and would like to prevent the user from closing it when clicking outside of the modal or when pressing escape. Instead, I want it to be closed when the user presses the finish button. How could I achieve this scenario?

16条回答
The star\"
2楼-- · 2020-01-25 03:36

Works too, data-backdrop="static" to click out and data-keyboard="false" to Esc in your div modal:

<div id="idModal" class="modal hide" data-backdrop="static" data-keyboard="false">
查看更多
Lonely孤独者°
3楼-- · 2020-01-25 03:39

Just add data-backdrop="static" and data-keyboard="false" attributes to that modal.

Eg.

<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">
查看更多
【Aperson】
4楼-- · 2020-01-25 03:42

If using JavaScript then:

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})

or in HTML:

<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">
查看更多
祖国的老花朵
5楼-- · 2020-01-25 03:47

You can Use Direct in bootstrap model also.

<div class="modal fade" id="myModal" data-keyboard="false" data-backdrop="static">
查看更多
再贱就再见
6楼-- · 2020-01-25 03:48
<button class="btn btn-primary btn-lg" data-backdrop="static" data-keyboard="false" data-target="#myModal" data-toggle="modal">
查看更多
Lonely孤独者°
7楼-- · 2020-01-25 03:48

You should use backdrop static , keyboard false. and can use close button off by using jQuery or can remove from modal html. Hope this help.

 $('#MyModal').modal({ backdrop: 'static', keyboard: false });
    $('#MyModal .close').css('display','none');
查看更多
登录 后发表回答