2012-06-12 26 views
2

我最近遇到一个问题,同时开发一个页面有多个TinyMCE。多个TinyMCE

<textarea style='width:90%;height:500px;' class='tinymce' name='message' id="mce_editor_0" placeholder='Long Message'>{if isset($message)}{$message}{/if}</textarea> 
<textarea style='width:90%;height:200px;' class='tinymce' name='signature' id="mce_editor_1" placeholder='Long Message'></textarea> 

$.ajax({ 
      url: "../action/getEmailTemplate?id="+id+'&type='+type 
     }).done(function (data) { 
      console.log("../action/getEmailTemplate?id="+id+'&type='+type); 
      console.log(data); 
      if(type=='email'){ 
       tinyMCE.execCommand('mce_editor_0', 'mceSetContent', false, data); 
      } 
      if(type=='sig'){ 
       tinyMCE.execCommand('mce_editor_1', 'mceSetContent', false, data); 
      } 
     }); 

而这不起作用。我误解了tinyMCE.execCommand背后的逻辑吗?

回答

5

这不行。你会发现正确的使用说明here

有generall命令,你可以调用使用TinyMCE的和有要求的编辑器实例编辑器专用命令:

tinymce.get('mce_editor_1').execCommand('mceCodeEditor', false, 5); 

您也可以使用以下方法来解决特定的编辑器

tinyMCE.execInstanceCommand('mce_editor_1', command, user_interface, value, focus)