How to determine if CKEditor is loaded?

0 votes
asked Aug 10, 2010 by friedkiwi

How do I find out if CKEditor is loaded? I've looked through the API docs, but could only find the loaded event. I want to check if CKEditor is loaded, because if I load it a second time, my textareas disapears.

4 Answers

0 votes
answered Aug 25, 2011 by kees-c-bakker

The loaded event didn't work for me. instanceReady worked:

CKEDitor_loaded = false;

CKEDITOR.on('instanceReady', function(){ CKEditor_loaded = true; }); 
0 votes
answered Aug 8, 2014 by convictions

I know this is a very old post, but in my research it kept coming up. I am dynamically loading the CKEditor through jQuery. I didn't want to load it multiple times since things start happening, as you found out.

Simple solution:

if (!window.CKEDITOR) {
    // (not loaded yet, your code to load it)
}
0 votes
answered Aug 28, 2015 by alex
var waitCKEDITOR = setInterval(function() {
    if (window.CKEDITOR) {
       clearInterval(waitCKEDITOR);
       //CKEDITOR.replace(...);
    }
}, 100/*milli*/);
0 votes
answered Aug 11, 2016 by jonathan-parker

Hope this helps someone.

I also load a page snippet with CKEDITOR functionality via AJAX and as such I have experienced many of the problems outlined in this question. This is my solution:

function setCk(id){
if(window.CKEDITOR){
    var _instId = CKEDITOR.instances[id];
    if(_instId == undefined){
        CKEDITOR.inline(id);
    }else{
        CKEDITOR.instances[id].destroy();
        CKEDITOR.inline(id);
    }
}

}

On each AJAX response for this snippet I inject a script element into the head with a call to setCk(textareaId). The trick being to destroy any previous CKEDITOR instances for the target ID & re-initialise CKEDITOR after each AJAX snippet load.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...