2

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

Community
  • 1
  • 1
user3354539
  • 1,245
  • 5
  • 21
  • 40

1 Answers1

4

Try calling this function in the onchange event

CKEDITOR.instances[i].updateElement();
Derek
  • 450
  • 5
  • 9
  • 1
    Whoa!!! Correction! This is the correct answer. My poor coding skills got it wrong. Then I re-tried it and it works. Thanks. – user3354539 Feb 26 '14 at 22:37
  • haha I was going to create a fiddle for you but good you got it to work :) – Derek Feb 27 '14 at 05:32
  • just posted a related question here - http://stackoverflow.com/questions/22063508/ckeditor-content-into-textarea-on-change-event-multiple-ckeditors-on-form – user3354539 Feb 27 '14 at 08:56