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

来源:互联网 发布:90后网络行为分析 编辑:程序博客网 时间:2024/05/21 22:42
参考文献:http://blog.csdn.net/fireofjava/article/details/48414207http://www.voidcn.com/blog/ynwso/article/p-296035.html
当bootstrap 模态框和select2配合使用的时候或出现 input 无法获取焦点的问题

产生的原因:

Bootstrap registers a listener to the focusin event which checks whether the focused element is either the overlay itself or a descendent of it - if not it just refocuses on the overlay. With the select2 dropdown being attached to the body this effectively prevents you from entering anything into the the textfield.You can quickfix this by overwriting the enforceFocus function which registers the event on the modal

解决办法:

我这次解决的办法就是把tabindex="-1"去掉就可以了

其他的解决办法:

<script>$(document).ready(function() {  $("#select2insidemodal").select2({    dropdownParent: "#myModal"  });});</script>
0 0
原创粉丝点击