最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - CKEditor Custom Properties Not Working and Getting Error - Stack Overflow

programmeradmin5浏览0评论

I am fairly new to CKEdtior and have just installed it on this website I'm working on, the version is 4.4.4

The editor itself loads into the page, but custom properties like language or uiColor aren't working, and with or without properties, I keep getting the error:

Uncaught TypeError: Cannot read property 'getEditor' of undefined

I know I'm doing something wrong, because it works in the samples. If it helps, the code is part of a Smarty template. I tried using an ID that doesn't have an underscore, and of course checking in different browsers—the error appears in IE, FF and Chrome.

Relevant bits of code:

<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>

I am fairly new to CKEdtior and have just installed it on this website I'm working on, the version is 4.4.4

The editor itself loads into the page, but custom properties like language or uiColor aren't working, and with or without properties, I keep getting the error:

Uncaught TypeError: Cannot read property 'getEditor' of undefined

I know I'm doing something wrong, because it works in the samples. If it helps, the code is part of a Smarty template. I tried using an ID that doesn't have an underscore, and of course checking in different browsers—the error appears in IE, FF and Chrome.

Relevant bits of code:

<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>
Share Improve this question edited Jul 15, 2017 at 18:23 Ynhockey asked Aug 27, 2014 at 14:31 YnhockeyYnhockey 3,9325 gold badges36 silver badges54 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 16

You cannot call CKEDITOR.replace() before the place where the relevant <textarea> is in the code. You can see this in the 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>

if you use class as param in CKEDITOR.replace( 'yourclass' ); it still replaces textarea to editor but generates the same error.

You can write a function named setTimeout().

Example:

setTimeout(function(){CKEDITOR.replace('id-textarea')},time);
发布评论

评论列表(0)

  1. 暂无评论