Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As mentioned in the comments on your original post, I'm assuming you're using CKEditor and in your jQuery ready function (or somewhere after your document loaded) you replace a textarea with an editor instance. CKEditor, like most WYSIWYG editors likes to reformat the text that you pass to it, making it valid markup, replacing special characters with HTML entities, wrapping your content in a paragraph, etc. This means although you haven't changed anything, the original and the reformatted content can be different.</p> <p>The initialisation of the editor instance is delayed and probably occurs after you've serialised your form. Even so, CKEditor is not strongly linked with the (now hidden) textarea that it's been created from, you need to call the editor's updateElement function to flush all changes. It usually does it automatically on form submit, that's why you're getting the reformatted content in your submit handler.</p> <p>So you just need to make sure you call the updateElement function before you're serialising the first time, for which the best place is after the editor has loaded. Luckily there is an event for that, assuming the following HTML markup:</p> <pre><code>&lt;form id="myForm"&gt; &lt;textarea name="test" id="myEditor"&gt;My random text&lt;/textarea&gt; &lt;/form&gt; </code></pre> <p>jQuery ready function:</p> <pre><code>$(function(){ function SerializeForm(){ // Make sure we have the reformatted version of the initial content in the textarea CKEDITOR.instances.myEditor.updateElement(); // Save the initial serialization form_data.edit_initial = $('#myForm').serialize(); } // You might as well leave it here in case CKEditor fails to load form_data.edit_initial = $('#myForm').serialize(); // Create editor instance CKEDITOR.replace('myEditor'); // Tap into CKEditor's ready event to serialize the initial form state CKEDITOR.instances.myEditor.on("instanceReady", SerializeForm); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload