填写含有OnReady内容的tinymce textarea?

时间:2012-10-24 16:55:38

标签: javascript jquery tinymce wysiwyg

这是我的tinymce代码。我正在准备活动中填充内容'Cust Details'的tinymce textarea。但即使在使用tinymce

附加文本区域后,tinyMCE.activeEditor也会计算为null
 $(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');
          }


    });

请告诉我如何在准备好的活动中填充微小的mce文本区域?

1 个答案:

答案 0 :(得分:8)

我有一段时间没有同样的问题......

尝试在init选项中设置 init_instance_callback 参数中的文本区域内容:

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

将此应用到您的代码段应该类似于:

$(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');}

        });}
    });