I have a custom-written CMS that uses CKEditor *(FCKEditor v3) for editing content. I'm also using the jQuery Validation plugin to check all fields for error prior to AJAX-based submission. I'm using the serialize() function to passing the data to the PHP backend.
Problem is, serialize manages to grab all fields correctly, except for the actual content typed in CKEditor. Like every other WYSIWYG editor, this one too overlays an iframe over an existing textbox. And serialize ignores the iframe and looks only into the textbox for content, which, of course, it doesn't find, thus returning a blank content body.
My approach to this is to create a hook onto the onchange event of CKEditor and concurrently update the textbox (CKEDITOR.instances.[textboxname].getData()
returns the content) or some other hidden field with any changes made in the editor.
However, since CKEditor is still in it's beta stage and severely lacks documentation, I can't find a suitable API call that'll enable me to do so.
Does anyone have any idea on how to go about this?
I solved this problem with the current version: http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js
After line 55 this.submit( function( event ) { - i added this code:
CKEDITOR.instances.wc_content1.getData()
will return the ckeditor dataCKEDITOR.instances.wc_content1.setData()
will set the ckeditor dataI think the user was asking about serializing, I was struggling serializing a form to submit and it was giving me a lot of issues.
This is what worked for me:
This should do it...
edit: added section to update textbox after pastes, too...
I have also been trying to fix this problem today. I realised that the reason the above code isnt working for me is because the CKEditor instance isnt ready yet when the document property is referenced. So you have to call the "instanceReady" event and within that the document's events can be used, because prior to that it just doesnt exist.
This example might work for you:
I've just released a CKEditor plugin for jQuery which will take care of all this in the background without any extra code: http://www.fyneworks.com/jquery/CKEditor/