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