TinyMCE textarea cannot edit

Here is the problem. On my php submit page, I have a form with several fields, including the text field that TinyMCE currently uses, and I also have the option to duplicate the existing form. The fact is that I can’t edit the second editor, which was duplicated, but the editor appears in the place of textarea. However, I can edit and save the first editor. I'm not sure if his mistake or just something I am wrong? I also tried updating TinyMCE, but did not work. Any idea?

function initTinyMCE() { tinyMCE.init({ mode : "textareas", //mode : "exact", elements : "mytextarea" theme : "simple" }); } initTinyMCE(); $(document).ready( function(){ $('a#addmore').live('click', function(){ //*clone the existing form and inserting form here* initTinyMCE(); }); $('a#toSubmit').live( 'click', function() { tinyMCE.triggerSave(); $('.editwork-form').submit(); }); }); 
+6
source share
2 answers

I can't get .clone() to work, nothing in the debug console either. However, my working solution is as follows, maybe this helps?

 initTinyMCE(); $("#append").live("click", function() { var ta_count = $("textarea").length; var elem = document.createElement("textarea"); $(elem).attr("id", ta_count.toString()); $(elem).appendTo("#ta_container"); initTinyMCE(); }); function initTinyMCE() { tinyMCE.init({ mode: "textareas", theme: "simple", theme_advanced_path: false }); }​ 

Instead of the .clone() element, I simply create a new textarea and add it to the container (using the count of all text areas on the page, as this is an identifier to make it unique) by invoking the tinyMCE initializer.

JsFiddle example

+3
source

Make sure your text fields have different identifiers, otherwise there will be no second instance of the editor! This is very important when creating instances of the tinymce editor.

+1
source

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


All Articles