亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

BootStrap模態(tài)框和select2合用時input無法獲取焦點(diǎn)的解決方法

 更新時間:2017年09月01日 14:00:56   作者:阿杰de博客  
在bootstrap的模態(tài)框里使用select2插件,會導(dǎo)致select2里的input輸入框沒有辦法獲得焦點(diǎn),沒有辦法輸入。怎么解決這個問題呢?下面小編給大家?guī)砹薆ootStrap模態(tài)框和select2合用時input無法獲取焦點(diǎn)的解決方法,一起看看吧

在bootstrap的模態(tài)框里使用select2插件,會導(dǎo)致select2里的input輸入框沒有辦法獲得焦點(diǎn),沒有辦法輸入.

解決方法:

1.

把頁面中的  tabindex="-1"  刪掉(測試成功):

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  <h3 id="myModalLabel">Panel</h3>
 </div>
<div class="modal-body" style="max-height: 800px">
<div id="myModal" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  <h3 id="myModalLabel">Panel</h3>
 </div>
<div class="modal-body" style="max-height: 800px">

可以在onshown方法里面做處理,主要原理就是因?yàn)閎ootstrap的tabindex='-1',占用了select2的tabindex='0',腳本做處理 模態(tài)框顯示出來后,將模態(tài)框的tabindex屬性刪掉

BootstrapDialog.show({
   onshown: function (dialogRef) {
    $("#"+dialogRef.getId()).removeAttr("tabindex");
  }
})

2.

重寫enforceFocus方法(測試發(fā)現(xiàn)沒有效果):

$.fn.modal.Constructor.prototype.enforceFocus = function() {};

總結(jié)

以上所述是小編給大家介紹的BootStrap模態(tài)框和select2合用時input無法獲取焦點(diǎn)的解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論