Fill tinymce text area with content in OnReady?

Here is my tinymce code. I fill the tinymce text area with the contents of “Cust Details” at the finished event. But tinyMCE.activeEditor evaluates to null even after adding a text area with tinymce

$(function() { appendTinyMCE(); function appendTinyMCE(){ tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "preview", // Theme options theme_advanced_buttons1 : "forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,formatselect,fontselect,fontsizeselect,sub,sup,|,bold,italic,underline,strikethrough", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", width : "640", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true });} alert("tinyMCE.activeEditor"+tinyMCE.activeEditor);// inyMCE.activeEditor is coming as null. Not getting why if(tinyMCE!=null && tinyMCE.activeEditor!=null) { tinyMCE.activeEditor.setContent('Cust Details'); } }); 

Please let me know how can I fill the tiny mce text area on the finished event?

+4
source share
1 answer

I had the same problem a while ago ...

Try adjusting the contents of the text area from the init_instance_callback parameter in the init parameters:

 init_instance_callback : function() { tinyMCE.activeEditor.setContent('Cust Details'); } 

Using this piece of code should look something like this:

 $(function() { appendTinyMCE(); function appendTinyMCE(){ tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "preview", // Theme options theme_advanced_buttons1 : "forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,formatselect,fontselect,fontsizeselect,sub,sup,|,bold,italic,underline,strikethrough", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", width : "640", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, init_instance_callback : function() { tinyMCE.activeEditor.setContent('Cust Details');} });} }); 
+8
source

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


All Articles