问题
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?
回答1:
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.
回答2:
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>
来源:https://stackoverflow.com/questions/8407175/ckeditor-doesnt-post-value