Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor Custom Properties Not Working and Getting Error

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>
like image 549
Ynhockey Avatar asked Aug 27 '14 14:08

Ynhockey


2 Answers

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>
like image 179
Reinmar Avatar answered Oct 23 '22 18:10

Reinmar


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

like image 45
user3410311 Avatar answered Oct 23 '22 16:10

user3410311