• support@answerspoint.com

Disable click outside of bootstrap model area to close modal


I am making a bootstrap website, with a couple of Bootstrap 'Modals'. I'm trying to customize some of the default features.

Problem is this; You can close the modal by clicking on the background. Is there anyway to disable this feature? On specifc modals only?



If you opening the modal by js use:

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

If you are using data attributes, use:

 <button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
    Launch demo modal

you can use the backdrop option. Passing this option with value 'static' will prevent closing the modal.

you also can pass {keyboard: false} to prevent closing the modal by pressing Esc.


  • answered 7 years ago
  • Community  wiki

Your Answer

    Facebook Share        
  • asked 7 years ago
  • viewed 2587 times
  • active 7 years ago

Best Rated Questions