multiple TinyMCE

元气小坏坏 提交于 2019-12-10 10:48:25

问题


I have recently encountered a problem while developing a page with multiple TinyMCEs.

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

And this does not work. Do I misunderstand the logic behind tinyMCE.execCommand?


回答1:


This won't work. You will find the correct usage description here.

There are generall commands you may call using tinyMCE and there are editor-specific commands called on an editor instance:

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

You may also use the following to address a specific editor

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


来源:https://stackoverflow.com/questions/10994269/multiple-tinymce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!