Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape? [duplicate]

If using JavaScript then: $(‘#myModal’).modal({ backdrop: ‘static’, keyboard: false }) in case of ‘show’ $(‘#myModal’).modal({backdrop: ‘static’, keyboard: false}, ‘show’); or in HTML: <a data-controls-modal=”your_div_id” data-backdrop=”static” data-keyboard=”false” href=”#”>

Disable click outside of bootstrap modal area to close modal [duplicate]

On Options chapter, in the page you linked, you can see the backdrop option. Passing this option with value ‘static’ will prevent closing the modal. As @PedroVagner pointed on comments, you also can pass {keyboard: false} to prevent closing the modal by pressing Esc. If you opening the modal by js use: $(‘#myModal’).modal({backdrop: ‘static’, keyboard: … Read more

Disallow Twitter Bootstrap modal window from closing

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 });

Bind a function to Twitter Bootstrap Modal Close

Bootstrap 3 & 4 $(‘#myModal’).on(‘hidden.bs.modal’, function () { // do something… }); Bootstrap 3: getbootstrap.com/javascript/#modals-events Bootstrap 4: getbootstrap.com/docs/4.1/components/modal/#events Bootstrap 2.3.2 $(‘#myModal’).on(‘hidden’, function () { // do something… }); See getbootstrap.com/2.3.2/javascript.html#modals → Events