ckeditor content into textarea on change event - beginner

心不动则不痛 提交于 2019-12-01 09:51:59

问题


I am trying to get the contents of my ckeditor to be entered into the associated textarea as the user enters the value into the ckeditor.

I have read several helpful threads, namely here and here, but I am going around in circles as my code experience and knowledge is not so great.

I understand how the ckeditor works and that I should be using the change event as described in the post.

I have managed to add the following jquery code to display the alert message when the user enters value into the ckeditor:

    for (var i in CKEDITOR.instances) {
        CKEDITOR.instances[i].on('change', function() {alert('value changed!!')});
    }

My text area code is:

<textarea id="id_a_description" rows="10" cols="40" name="a_description" class="input-95pc" style="visibility: hidden; display: none;"></textarea>

How do I change the jquery code above to enter the value from the ckeditor into the text area as the users types using the ckeditor change event?

This would really help me out as I am so frustrated at not being able to solve this even-though I think I am very close to the solution..


回答1:


Try calling this function in the onchange event

CKEDITOR.instances[i].updateElement();


来源:https://stackoverflow.com/questions/22035396/ckeditor-content-into-textarea-on-change-event-beginner

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