Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ckeditor content into textarea on change event - multiple ckeditors on form

With a lot of help I finally got the CKEditor to update the associated text area. See the post here.

However, I am stumped of how to get the CKEditor to update each associated text area when there is more than 1 CKEditor on the form.

Here is the jquery that I currently have. It only updates the last CKEditor associated text area on the form:

    for (var i in CKEDITOR.instances) {
        CKEDITOR.instances[i].on('change', function() { CKEDITOR.instances[i].updateElement() }); //update the relative hidden textarea.
    }

How do I update each associated CKEditor text area when I have 5 or 10 CKEditors on the form?

like image 662
user3354539 Avatar asked Feb 27 '14 08:02

user3354539


1 Answers

For each instance of the ckeditor that you want to install on your page, add the following code to your jquery script:


CKEDITOR.instances['id_of_text_area'].on('change', function() { CKEDITOR.instances['id_of_text_area'].updateElement() });


The above JavaScript should replace the code I have displayed in the original question.

I hope this will help some one.

like image 137
user3354539 Avatar answered Oct 07 '22 21:10

user3354539