How to listen to basic events in CKEditor?

lisak picture lisak · Apr 19, 2011 · Viewed 31.8k times · Source

I can't figure out how to listen to focus, click, onKeyUp and other basic dom events in ckeditor. In the events summary there is only a few events regarding the lifecycle of ckeditor. And the "textArea" of ckeditor is an iframe, and it's html itself, so it is not clear on what dom node to listen.

Answer

lisak picture lisak · Apr 21, 2011

It's not a big deal, just do the following, works for focus, blur, click etc.

var ckeditor = CKEDITOR.instances['textArea_id'];
ckeditor.on('focus', fnHandler, context, data, priority);

or a jQuery example :

$(document).ready(function () {
    $('#YOUR_TEXTAREA_ID').ckeditor(ckeditor_config);

    CKEDITOR.instances.YOUR_TEXTAREA_ID.on('blur', fnHandler);
});

I don't know when this support appeared, but it definitely works for 3.5.x