Posted on

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;
		}
	}
});

8 thoughts on “CKEditor save button callback

  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?

    1. Do you have the “save” plugin? Sorry I have not seen your comment before

  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. Wasted a morning on this until I found your not. Thanks!!!

  4. Men! thank you so much! this is what i need! thanks! 🙂

  5. Thank you so much!

  6. 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.

  7. Man! Thank you so much! You don’t realize how glad I am that I found that! After so many wasted hours you made my day! Thanx! 🙂 🙂 🙂

Leave a Reply

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