Adding multiple CKEditor instances in jquery

I am experimenting with various WYSIWYG javascript text areas. If I try to put CKEditor on every <textarea> on my screen using jquery, all editors will be displayed well, but they are not saved. I tried:

 $(function() { $('.editors').ckeditor(); }); 

and

 $(function() { $('.editors').each(function(index, element){ $(element).ckeditor(); }); }); 

In both cases, each text area contains a CKEditor, but it is not saved. If I manually add all editors using

 $(function() { CKEDITOR.replace('contactText'); CKEDITOR.replace('edit_footer_text'); CKEDITOR.replace('termsText'); }); 

or

 $(function() { $('#contactText').ckeditor(); $('#edit_footer_text').ckeditor(); $('#termsText').ckeditor(); }); 

All three fields have editors, and they are saved.

I am trying to put some code in a standard template for this project, so if we want editors in text areas, they just need to add the β€œeditors” class to them, so I'm looking for jQuery Solutions. This worked with tinima:

 $(function() { $('.editors').tinymce({ script_url : '/common/tiny_mce/tiny_mce.js', // General options mode : "textareas", theme : "advanced", }) }); 
+6
source share
1 answer

In fact, the jQuery Adapter for CKEditor, by default does not update the form element, you need to replace the editor with the current identifier.

 $(function() { $('.editors').each(function(){ CKEDITOR.replace( $(this).attr('id') ); }); }); 

Link

+13
source

Source: https://habr.com/ru/post/892771/


All Articles