CKEditor save button callback

I am sharing this since it was impossible to find with Google.

Before CKEditor 4.2 if you wanted to handle the save event with a custom function, you had to write your own plugin.

Now all you need to do is to specify the callback upon initialization:

CKEDITOR.replace('ckeditor', {
	on: {
		save: function(evt)
		{
			// Do something here, for example:
			console.log(evt.editor.getData());

			// If you want to prevent the form submit (if your editor is in a <form> element), return false here
			return false;
		}
	}
});

Join the conversation

8 Comments

  1. I use ckeditor inline, so it is not inside form element. It doesn’t show the save button even though that I set it in toolbar config. Do you know how to enable it?

  2. Man… Really REALLY Thank you! THANK YOU! I have been looking for this like since two days and wasn’t able to find anything.

  3. It is definitely impossible to find information in version 4 .

    Now, I ‘m having issues in replacement obtaining this:

    • “the getEditor() is not function”.

    I changed ” ckeditor ” by the id of the textarea and got another error:

    “The editor CKEditor instance is already connected to the element provided”.

    Fortunately I could find the solution through a callback in ” instanceReady ” by Matthew in:
    http://stackoverflow.com/a/19868809/2904959

    Thanks.

Leave a comment

Your email address will not be published. Required fields are marked *