Domanda

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?

È stato utile?

Soluzione

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top