shafeequemat
shafeequemat

Reputation: 1052

TypeError: c[a] is undefined in CKEditor

I am loading ckeditor.js file using $.getScript and in callback I am initiating CKEditor. But it is showing an error TypeError: c[a] is undefined. Here is my code. How can I solve this issue?

$.getScript("ckeditor.js", function (data, textStatus, jqxhr) {
    if (textStatus == 'success' && jqxhr.status == 200) {
        CKEDITOR.replace( 'commentBox',
        {
            toolbar :
            [
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Blockquote'] },
                { name: 'insert', items : [ 'Table','HorizontalRule','SpecialChar' ] },

                { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
                { name: 'colors', items : [ 'TextColor','BGColor' ] }
            ]
        });
    }
});

Upvotes: 5

Views: 4966

Answers (2)

Viral
Viral

Reputation: 1337

Re. https://stackoverflow.com/a/50719171/6462713

I had same issue. I have also loaded all supported languages in "/lang" folder. Basically my issue was - CKEditor isn't identifying properly its own folder path. So I set a CKEDITOR_BASEPATH variable before loading CKEditor.

It's briefly said here: (but there might be other places where it's explained better.) http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.basePath

Therefore implementation will be like this:

<script>
  window.CKEDITOR_BASEPATH = 'http://example.com/path/to/libs/ckeditor/';
</script>

In my case i used window.CKEDITOR_BASEPATH = '/app/storereport/ckeditor/';

Then load the main ckeditor.js script. Hope this may help you.

<script type="application/javascript"/>
$(document).ready(function (){
    CKEDITOR.replace( 'product_content' );  // ID of element
});
</script>

Upvotes: 3

Pete Bradford
Pete Bradford

Reputation: 61

I was getting the same error in similar circumstances.

I checked the formatted source in Chrome and discovered that this was being caused by the Format plugin trying to load its labels from the CKEDITOR.language object.

Turns out I didn't have en-gb included in my build and apparently it won't automatically fall back to straight en. Adding English (United Kingdom) to the build corrected the issues.

Upvotes: 6

Related Questions