I have a very interesting issue, using CKEDITOR. I'm doing the following:
I have an instance of CKEDITOR, and I have a form with hidden inputs. Before submitting the form, the value of CKEDITOR is entered in a hidden input field. So I have:
$('#form_hidden_input').val(CKEDITOR.instances.editor.getData());
When posting (so submitting the form, I am able, to access the value of the input with $_POST['form_hidden_input']
. So far, so good. But when I now try, to insert the value I got into CKEDITOR again, it fails. What I do is
CKEDITOR.instances.editor.insertHtml('<?=$_POST['form_hidden_input'];?>');
When I echo the content of $_POST['form_hidden_input']
everything seems to be fine, but with insertHtml(), I get a "Uncaught SyntaxError: Unexpected token ILLEGAL", in Sources of of Developer Console (or when clicking on the error), the line looks like that:
CKEDITOR.instances.editor.insertHtml('<p>asfa</p>
');
Be aware, that ');
appears in the next line, anyway it should work, but I think, this is the only point, where the problem could appear... The question is, why is there a wordwrap, and how can I prevent that, or get it working anyway?
Figured out how to do it:
when I do that:
$content = $_POST['form_old_data'];
$content = str_replace("
", "", $content);
$content = str_replace("", "", $content);
CKEDITOR.instances.editor.insertHtml('<?=$content;?>');
it works.