How to disable Escape Key for Twitter Bootstrap Modals?

后端 未结 7 932
执念已碎
执念已碎 2020-12-13 17:44

In a shown modal there is a form. If I focus on an input field (any field for that matter) and press ESC key, that modal is hidden. However, if I don\'t focus on a form fiel

7条回答
  •  无人及你
    2020-12-13 18:10

    Twitter's Bootstrap modal.js (see http://getbootstrap.com/2.3.2/javascript.html#modals) itself has keyboard true or false Boolean. You can avoid escape keypress and click outside the modal using following script:

        $(function () {
            $('.modal').modal({
                show: true,
                keyboard: false,
                backdrop: 'static'
            });
        });
    

    working demo :

    $(function () {
         $('.modal').modal({
          show:true,
          keyboard: false,
          backdrop: 'static'
        });
    });
     
            
            
            
    
            
            
    
            Hello, world!
          
          
           
            
            
            
          
          
          
    
          

提交回复
热议问题