2
votes

I have webpage (index.pl), in it's div (id = 'right') i have dynamically loaded a page(editor.pl) containing textarea.To change this textarea as TinyMce editor I have dyanamically loaded a js file (include_tiny_mce.js) which has tinyMce.init() function as below :

$.ajax({
    type:'POST',
    url:'editor.pl',
    success:function(msg){
    $("#right").html(msg);
    $("head").append("<script src='/include_tiny_mce.js'></script><script src='/scripts.js'></script>");

    },

Now all this is working fine and all textareas are changed to tinyMce but when I am using
tinyMCE.activeEditor.setContent("hello world");
from a js file (script.js, already included in index.pl) to set content in tinyMce it is not showing the content. Anyone can tell me the solution for this ?

1

1 Answers

7
votes

The variable activeEditor gets set when you first "activate/use" it (like clicking into it). In case you are using only one single editor you may use tinymce.editors[0] :

tinymce.editors[0].setContent("hello world");

In all other cases use the tinymce instance object this way

tinymce.get('right').setContent("hello world");