Close Bootstrap Modal
Put modal(‘toggle’) instead of modal(toggle) $(function () { $(‘#modal’).modal(‘toggle’); });
Put modal(‘toggle’) instead of modal(toggle) $(function () { $(‘#modal’).modal(‘toggle’); });
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=”#”>
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
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 });
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
If the modal container has a fixed or relative position or is within an element with fixed or relative position this behavior will occur. Make sure the modal container and all of its parent elements are positioned the default way to fix the problem. Here are a couple ways to do this: Easiest way is … Read more