最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IE11下CKEditor在Bootstrap Modal中下拉問題的解決

 更新時間:2019年09月25日 10:53:36   作者:yulj  
這篇文章主要介紹了IE11下CKEditor在Bootstrap Modal中下拉問題的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

最近在項目中需要在Bootstrap Modal彈出框中載入CKEditor。

初始化CKEditor以后,在IE11下,格式/字體/顏色的下拉會閃現(xiàn)一下后就消失,但在chrome和firefox下沒問題。

主要原因是IE11下,點擊CKEditor,觸發(fā)了focusin.modal事件,原modal enforceFocus函數(shù)的if條件成立,bootstrap modal獲取焦點,CKEditor下拉失去焦點,所以下拉出現(xiàn)閃現(xiàn)。

Google了以后找到了一個解決方案

這個解決方案中,加了判斷后,可以避免modal獲取焦點,但好像modal一直都不會trigger了。

我做了一下修改,以下代碼是在原modal enforceFocus函數(shù)的基礎(chǔ)上添加了!$(e.target.parentNode).closest(".cke").length判斷條件,也就是說在原判斷條件+未點擊在CKEditor上,則modal獲取焦點。

代碼的執(zhí)行順序是jQuery、bootstrap再執(zhí)行此段代碼。

$.fn.modal.Constructor.prototype.enforceFocus = function() {
 $(document)
  .off('focusin.bs.modal')
  .on('focusin.bs.modal', $.proxy(function (e) {
  if (document !== e.target &&
   this.$element[0] !== e.target &&
   !this.$element.has(e.target).length &&
   !$(e.target.parentNode).closest(".cke").length) {
   
   this.$element.trigger('focus')
  }
  }, this))
};

在項目中測試了一下未發(fā)現(xiàn)問題。 

附 bootstrap.js中enforceFocus函數(shù)代碼對比

Modal.prototype.enforceFocus = function () {
 $(document)
  .off('focusin.bs.modal') // guard against infinite focus loop
  .on('focusin.bs.modal', $.proxy(function (e) {
  if (document !== e.target &&
   this.$element[0] !== e.target &&
   !this.$element.has(e.target).length) {
   this.$element.trigger('focus')
  }
  }, this))
 }

this.$element表示modal對象。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

温州市| 含山县| 毕节市| 友谊县| 广灵县| 潜山县| 金溪县| 平原县| 武穴市| 井冈山市| 平原县| 连南| 府谷县| 丰城市| 宜君县| 岱山县| 习水县| 临泽县| 运城市| 余干县| 平定县| 海淀区| 渝北区| 合作市| 芷江| 榕江县| 霍山县| 随州市| 广河县| 岢岚县| 甘泉县| 民县| 开原市| 晋江市| 武陟县| 乌鲁木齐市| 阳春市| 德清县| 南岸区| 东阿县| 久治县|