CkEditor Doesn't post value

非 Y 不嫁゛ 提交于 2019-12-07 14:58:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!