我想实现一个功能。使用下拉框来控制fckeditor的toolbar。即当选择第一个选项的时候,fckeditor的toolbar是MailTemplate。而当我选择第二个下拉选项时候,页面中的fckeditor的toolbar则变成SMSTemplate。
我的页面代码是   <select id="ggTempletsType" class="common" name="ggTempletsType">
    <option value="MAIL">邮件模版</option>
    <option value="SMS">短信息模版</option>
  </select> <div class="right" style="float:left ;height:100%;border: 1px solid #cccccc;">
<fck:editor  id="content" basePath="/common/fckeditor/"
     height="500"
     width="750"
     skinPath="/common/fckeditor/editor/skins/silver/"
     toolbarSet="MailTemplate"
    
     </fck:editor>
      </div><!--js-->
<script type="text/javascript">
$("#ggTempletsType").click(function() {
  var oEditor = FCKeditorAPI.GetInstance("content");
  if($("#ggTempletsType option:selected").val() == "MAIL"){
   oEditor.ToolbarSet = "MailTemplate";
        //我设置了toolbarset选项,但是不自动该如何使页面正常切换编辑器
   //oEditor.ReplaceTextarea() ;
        //oEditor.Create();
  }else{
    oEditor.ToolbarSet = "SMSTemplate";
    //oEditor.ReplaceTextarea() ;  }
}); 
  
</script>

解决方案 »

  1.   

    顶一下吧~
    是重新加载fckeditor所在div的innerHTML吗?
    但应该如何进行加载?
      

  2.   

    换个问题
    如何给editor附默认值
    editor.Value = '<bean:write name="ggTempletsDto" property="tempContext" filter="true" />';//这样写编辑器就加载不了了。
    <logic:equal name="tempType" value="MAIL">
      var editor = new FCKeditor("ggTempletsTempContext"); 
      editor.BasePath = "/common/fckeditor/";
                      editor.Height = "500";
      editor.Width = "700";
                      editor.ToolbarSet = "Mail";
      editor.Value = '<bean:write name="ggTempletsDto" property="tempContext" filter="true" />';
                      editor.Create();
     </logic:equal>
      

  3.   

    没明白到底问题是什么?是说如何变换fck的内容?
    fck现在已经改名ckeditor了,如果在ckedit中是这样动态变换先将ckeditor的内容赋值给某个隐藏div中
    $("#contentDiv").html(data.SERVICE_CONTENT);
    将div的内容设置到ckeditor中
    CKEDITOR.instances.SERVICE_CONTENT.setData($("#contentDiv").text());
      

  4.   

    我一楼的问题是想问如何根据下拉框动态的替换fckeditor的工具条?而第二个问题已经解决了。
      

  5.   

    好像是在创建编辑框的时候就确定了吧?可以通过另外在创建一个fckedit解决,同时隐藏另外一个,或者直接将另外一个编辑框从html代码里面移除