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