Flat Cat
Flat Cat

Reputation: 916

CKEditor with jQuery output is chopped, possibly because of special characters

I have the following code that correctly generates the CKEditor:

<script>
$(function(){
  $("#newWrite_body").ckeditor({
                                 extraPlugins : 'autogrow',
                                 autoGrow_maxHeight : 800});
});
</script>

Then I grab some text from a web page, paste it into the editor, and alert the text back upon submitting it shows:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
       made a prediction that would forever change her life.</p>
<p>
    &quot;I won&#39;t see it, I&#39;m too old now, but it&#39;s going to be 
    really bad,&quot; she recalls him saying on a warm summer night after 
    returning from a moose hunt. The two were standing on a hill that overlooks 
    the birch-and-spruce-lined river here in far northwest Canada.</p>

But when I echo it back from the PHP code before the insert, it is reduced to:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
    made a prediction that would forever change her life.</p>
<p>

Apparently the special characters are being dropped. All my attempts to escape them and/or convert them have been futile.

What is the proper way to convert these from CKEditor's text to a POST-able value in PHP?

Upvotes: 0

Views: 747

Answers (2)

Flat Cat
Flat Cat

Reputation: 916

I finally found the answer. There is a Javascript built-in function called "escape". So this worked:

var text = escape(str);
// THEN POST STRING VIA AJAX

And this is with ajax.

Upvotes: 1

steve_c
steve_c

Reputation: 6255

There's a config setting inside ckEditor called CKEDITOR.config.htmlEncodeOutput

That may be what you want.

ckEditor Configuration Documentation

Upvotes: 0

Related Questions