Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ckeditor jquery plugin and the blur event

I'm currently working with ckeditor and i'm using the jquery plugin for this editor for instantiating everything when the document is ready. What I need to do is setup a blur event for the instance of ckeditor that is being created. The below code is what I'm using to instantiate ckeditor.

$("textarea.editor").ckeditor();

What I'm trying to do is something like:

$("textarea.editor").blur();

Is there a way to do this with ckeditor using the jquery plugin for it?

like image 944
Joe.Ingalls Avatar asked Dec 21 '25 06:12

Joe.Ingalls


1 Answers

You need to bind your handler to the editor instance not to the textarea itself. This binds an on-blur-handler to your editor instance:

var editor = CKEDITOR.instances['your_textarea_id'];

if (editor) {
    editor.on('blur', function(event) {
        // Do something, Example: disable toolbar:
        $("#cke_top_" + event.editor.name).css("display", "none");
    });
}   

(Inspired by skunkwerk@cksource-forum.)

like image 179
Tapper Avatar answered Dec 22 '25 18:12

Tapper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!