3

When a form with a textarea using CkEditor is submitted using ajax the post is empty on the server side.

If I remove CkEditor, the value is posted. Any ideas?

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Sebastien
  • 240
  • 2
  • 7
  • 16
  • 1
    If by ajax you mean that your not using postback and only callback, then CKEditor will not update the underlaying element unless told to. – Zee Dec 07 '11 at 10:58

3 Answers3

25

On submit, run this code:

for (instance in CKEDITOR.instances) {
    CKEDITOR.instances[instance].updateElement();
}

.. basically for AJAX, you need to force CKEditor to update your textareas so they contain the data you see in the CKEditor windows. See this question for more details.

Community
  • 1
  • 1
Wick
  • 1,222
  • 2
  • 15
  • 21
0

You don't really need to update anything with JS. All you have to do is to make sure your textarea (the one you replace with CKEDITOR.replace() on $(document).ready()) has the same name as the property you want to set value of, e.g.:

<textarea id="editor" name="Body">@Model?.Body</textarea>
0

This works for me:

  CKEDITOR.replace( 'content' );
  function updateAllMessageForms()
   {
    for (instance in CKEDITOR.instances) {
          CKEDITOR.instances[instance].updateElement();
   }
  }