Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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' ] }
            ]
        });
    }
});
like image 893
shafeequemat Avatar asked Apr 13 '17 10:04

shafeequemat


2 Answers

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.

like image 137
Pete Bradford Avatar answered Oct 03 '22 05:10

Pete Bradford


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>
like image 36
Viral Avatar answered Oct 03 '22 07:10

Viral