2016-02-13 125 views
0

我已經爲TinyMCE編寫了一個插件,它將用其屬性生成的內容替換自己。這在Chrome和FF中工作正常,但它不適用於IE11。TinyMCE沒有選擇IE11中的元素

當我處理文檔以找到自定義標籤並將其替換爲生成的內容時,我使用editor.selection.select(element)。這無法選擇IE11中的元素。

的jsfiddle:https://jsfiddle.net/bpstoxin/bsz69zcv/1/

代碼摘錄

  tinymce.each(editor.dom.select(tagName, node), function(element) { 
       if (element.parentNode) { 
        editor.selection.select(element); 
        editor.selection.setContent(element.getAttribute('data-contents')); 
       } 
      }); 

由於元素沒有得到選擇,其內容被插入到文檔中,而不是替換我的自定義標籤的頂部。

這是TinyMce的錯誤,還是我做錯了什麼?請記住,這是我的插件縮小版本來演示問題。

回答

0

我不明白爲什麼你在這種情況下使用選擇試試這個。

tinymce.each(editor.dom.select(tagName, node), function(element) { 
     if (element.parentNode) { 
      // BUG: For some reason, this is failing in IE 11 
      var dataContent = element.getAttribute('data-contents'); 
      element.outerHTML = dataContent.toString(); 
     } 
    }); 
+0

我已經能夠使這種方法的工作。這種方法的問題是我必須手動啓動所有事件(BeforeSetContent,SetContent)。現在情況良好,但如果他們改變實施方式,將會變得脆弱。 –