Reputation: 15329
I have a web form that I'm $.posting that contains a CKEditor textarea.
$(document).ready(function() {
CKEDITOR.replace('html');
CKEDITOR.config.htmlEncodeOutput = true; //seems to have no effect
$('#save').click(function() {
$.post('/async.php?a=save-slide', $('#slideForm').serialize(),
function(json) {
console.log(json);
}, 'json');
});
});
I have two problems:
Any ideas on how I can get the contents and safely POST xml-friendly data?
Upvotes: 1
Views: 2301
Reputation: 21630
I use the following generic method to move ckeditor contents back into the text area they were attached to:
var $editors = $("textarea.editor");
if ($editors.length) {
$editors.each(function () {
var instance = CKEDITOR.instances[this.id];
if (instance) { $(this).val(instance.getData()); }
});
}
If your situation is simpler there is no need for the loop.
There is also the jquery helper that is handy for this sort of thing.
Upvotes: 1