4

这是我的 tinymce 代码。我在准备好的事件中使用内容“客户详细信息”填充 tinymce 文本区域。但是即使在文本区域附加了 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 文本区域?

4

1 回答 1

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

        });}
    });
于 2012-10-24T17:13:37.697 回答