bootstrap模态框modal和select2合用时input无法获取焦点

场景:bootstrap模态框modal和select2合用时input无法获取焦点,导致输入法一直闪动,不能输入中文

解决办法: 
1、把页面中的 tabindex=”-1” 删掉;

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Panel</h3>
  </div>
<div class="modal-body" style="max-height: 800px">

 

 

2、重写enforceFocus方法:

$.fn.modal.Constructor.prototype.enforceFocus = function() {};

 

posted @ 2020-08-14 14:03  醒日是归时  阅读(251)  评论(0编辑  收藏  举报