2014-08-27 97 views
5

我是相當新的CKEdtior和剛剛安裝了這個網站我工作時,版本是4.4.4CKEditor的自定義屬性沒有工作,得到錯誤

編輯器本身加載到頁面,但如語言或的UIColor自定義屬性不工作,並且有或沒有的特性,我不斷收到錯誤:

Uncaught TypeError: Cannot read property 'getEditor' of undefined 

我知道我做錯了什麼,因爲它的工作原理樣品英寸如果有幫助,代碼是Smarty模板的一部分。我嘗試使用一個沒有下劃線的ID,當然在不同的瀏覽器中檢查 - 錯誤出現在IE,FF和Chrome中。代碼

相關位:

<script type="text/javascript" src="ckeditor/ckeditor.js"></script> 
<script type="text/javascript"> 
    {literal} 
    CKEDITOR.replace('show_description', 
    { 
     language: 'he' 
    }); 
    {/literal} 
</script> 

<textarea name="show_description" id="show_description" class="ckeditor"></textarea> 

回答

16

如有關<textarea>是在代碼中發生之前你不能叫CKEDITOR.replace()。您可以在replace by code sample看到:

<textarea cols="80" id="editor1" name="editor1" rows="10">content</textarea> 
<script> 

    // This call can be placed at any point after the 
    // <textarea>, or inside a <head><script> in a 
    // window.onload event handler. 

    // Replace the <textarea id="editor"> with an CKEditor 
    // instance, using default configurations. 

    CKEDITOR.replace('editor1'); 

</script> 
3

如果使用類作爲CKEDITOR.replace參數( 'yourclass');它仍然將textarea替換爲編輯器,但會生成相同的錯誤。

-1

您可以編寫一個名爲settimeout()的函數。

例子:

setTimeout(function(){CKEDITOR.replace('id-textarea')},time); 
+0

的名字是錯的,這是'setTimeout'。請參閱https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout – Stephan 2017-11-08 11:03:45

相關問題