user3354539
user3354539

Reputation: 1245

ckeditor content into textarea on change event - beginner

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..

Upvotes: 2

Views: 3883

Answers (1)

Derek
Derek

Reputation: 480

Try calling this function in the onchange event

CKEDITOR.instances[i].updateElement();

Upvotes: 4

Related Questions