您的位置:首页 > Web前端 > BootStrap

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

2016-08-21 23:01 441 查看
更多内容: http://blog.yuhai.win

参考文献:
 http://blog.csdn.net/fireofjava/article/details/48414207 http://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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bootstrap select