国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

BootStrap模態框和select2合用時input無法獲取焦點的解決方法

2019-11-19 15:35:13
字體:
來源:轉載
供稿:網友

在bootstrap的模態框里使用select2插件,會導致select2里的input輸入框沒有辦法獲得焦點,沒有辦法輸入.

解決方法:

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方法里面做處理,主要原理就是因為bootstrap的tabindex='-1',占用了select2的tabindex='0',腳本做處理 模態框顯示出來后,將模態框的tabindex屬性刪掉

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

2.

重寫enforceFocus方法(測試發現沒有效果):

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

總結

以上所述是小編給大家介紹的BootStrap模態框和select2合用時input無法獲取焦點的解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜兰县| 徐水县| 将乐县| 高碑店市| 利川市| 定结县| 南阳市| 家居| 福鼎市| 长春市| 昌图县| 怀远县| 汶川县| 娄底市| 双峰县| 双江| 平安县| 囊谦县| 什邡市| 华池县| 翁源县| 西充县| 航空| 耿马| 辽宁省| 鄄城县| 秦安县| 惠安县| 肇东市| 涟水县| 三门县| 洛阳市| 凤冈县| 河池市| 四川省| 肇东市| 土默特左旗| 武安市| 南昌市| 淮安市| 平泉县|