The page cannot be closed when modal encounters the Esc key in bootstrap

  • 2020-05-12 02:11:32
  • OfStack

bootstrap provides us with many convenient page controls, and modal is one of them. Many people have problems with using modal when the esc key is pressed and cannot be turned off, even if the keyboard option is explicitly passed in.

$('#editFormItemModal').modal({show:true, keyboard:true});

This problem has appeared since version 2.1. It is also very easy to solve this problem by adding one tabindex attribute to div where modal is located:

< div class="fade modal" tabindex="-1" >

The problem is simple, it's easy to fix, and I hope it helps.


Related articles: