gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 02:33:03 26 4
gpt4 key购买 nike

我有网页(index.pl),在它的div(id ='right')中我动态加载了一个包含textarea的页面(editor.pl)。要将此文本区域更改为 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>");

},

现在这一切都工作正常,所有文本区域都更改为tinyMce,但是当我使用
tinyMCE.activeEditor.setContent("hello world");
时我正在使用 .js 文件(script.js,已包含在index.pl中)来设置tinyMce中的内容,但它没有显示内容。谁能告诉我这个问题的解决方案?

最佳答案

变量 activeEditor 在您第一次“激活/使用”它(例如单击它)时被设置。如果您只使用一个编辑器,您可以使用 tinymce.editors[0] :

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

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

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

关于jquery - 在动态加载的tinyMCE编辑器中设置内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11289599/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com