Reputation: 285
I'm trying to prevent users from closing the modal without pressing the close button (normally you can tap away from the modal and it will close), however I can get it from not closing, but the close button still doesn't work!:
$('#manageRooms').on('hide.bs.modal', function (e) {
$('#manageClose').click(function (event) { //Have they pressed the close button?
$(this).data('clicked', 'yes');
}
);
if (!data) return e.preventDefault(); // stops modal from being hidden
})
Upvotes: 0
Views: 73
Reputation: 1818
I'm not sure that works but... you can try something like this:
$('#manageRooms').on('hide.bs.modal', function (e) {
if(!($(event.delegateTarget).is($('#manageClose')))) return e.preventDefault();
})
if the modal plugin not have a different way to set the closing prop.
Upvotes: 0
Reputation: 510
$('#myModal').modal({ backdrop: 'static', keyboard: false })
if html
<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">
Upvotes: 2
Reputation: 2017
If you are using bootstrap modal than writing this below code can do it.
.modal({ backdrop: 'static', keyboard: false })
Upvotes: 2