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

更多内容: 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值