Here is my tinymce code . I am populating the tinymce textarea with content 'Cust Details' at on ready event. But tinyMCE.activeEditor evaluates as null even after appending the 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 i can populated the tiny mce text area on ready event?
I had the same issue a while back...
Try setting the the text-area content from the init_instance_callback param in init options:
init_instance_callback : function() {
tinyMCE.activeEditor.setContent('Cust Details');
}
applying this to your code snippet should look something like:
$(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');}
});}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With