Everytime a page loads I need to load text into the CK Editor using JQuery, in order to get data from CK Editor I use
var editor_data = CKEDITOR.instances['editor1'].getData();
now is there a similar function I could use to put the data back into the editor?
I'm using ajax to set the data like this
$.ajax({ type: "POST", url: "/inc/ajax/basic.php?menu_id="+menu_id+"&info=3", success: function(msg){ CKEDITOR.instances['editor1'].setData(msg); } });
What am I doing wrong
CKEditor automatically sets the content of the new textarea using what is originally within the old, replaced one. In other words, it's sufficient to change the content of the textarea and only then call the replace command. This would be the code: document.
Thanks to these changes CKEditor 4 automatically works with the official jQuery Form Plugin for Ajax-based forms. It does not require any action from the developer's side to support it.
[form name]. [textarea name]. value=data; $('#textareaID'). val(data);
Try this:
CKEDITOR.instances['editor1'].setData(html)
Where 'html' is a string containing content to edit.
Because its not an array then just replace the instance like this
CKEDITOR.instances.editor1.setData(html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With