更多内容: 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>