在动态加载的tinyMCE编辑器中设置内容

r.b*_*waj 2 jquery tinymce

我有网页(index.pl),在它的div(id ='right')我已动态加载包含textarea的页面(editor.pl) .要将此textarea更改为TinyMce编辑器,我已经动态加载了一个js文件(include_tiny_mce. js)具有tinyMce.init()函数如下:

$.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>");

    },
Run Code Online (Sandbox Code Playgroud)

现在这一切都运行正常,所有textareas都改为tinyMce但是当我使用
tinyMCE.activeEditor.setContent("hello world");
js文件(script.js,已经包含在index.pl中)来设置tinyMce中的内容时,它没有显示内容.任何人都可以告诉我解决方案吗?

Tha*_*ama 7

当您第一次"激活/使用"它时(例如点击它),变量activeEditor就会被设置.如果您只使用一个编辑器,您可以使用tinymce.editors[0]:

tinymce.editors[0].setContent("hello world");
Run Code Online (Sandbox Code Playgroud)

在所有其他情况下,以这种方式使用tinymce实例对象

tinymce.get('right').setContent("hello world");
Run Code Online (Sandbox Code Playgroud)