CKEDITOR.inline之后如何使用CKEDITOR.replace [英] How to use CKEDITOR.replace after CKEDITOR.inline

查看:372
本文介绍了CKEDITOR.inline之后如何使用CKEDITOR.replace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以内联模式使用CKEDITOR,每页有多个编辑器。要创建它们,我在HTML中使用< textarea> 标记,然后运行执行 CKEDITOR.inline()在加载网页后立即针对它们。

I'm using CKEDITOR in inline mode with multiple editors per page. To create them, I use <textarea> tags in the HTML and then run a script that executes CKEDITOR.inline() against each of them as soon as the webpage is loaded.

只要我在 config.js中定义最终配置,该方法就可以正常工作,但是我需要来动态更新其中一个配置选项。

That works fine as long as I define my final configuration in "config.js", but I need to update one of the configuration options dynamically.

这是我的脚本,使用JQuery循环通过< textarea> 加载页面后的元素。作为诊断,我将 CKEDITOR.replace()夹在 alert 语句之间。此代码用编辑器替换了第一个< textarea> 并显示了第一个 alert 语句。但是,它在 CKEDITOR.replace()语句中退出,并且从不显示第二个 alert

Here's my script, using JQuery to loop thru the <textarea> elements after the page is loaded. As a diagnostic, I have the CKEDITOR.replace() sandwiched between alert statements. This code replaces the first <textarea> with an editor and displays the first alert statement. However, it quits during the CKEDITOR.replace() statement and never displays the second alert.

$(function () {
    $("textarea").each(function () {
        editor = CKEDITOR.inline($(this)[0]);
        alert("Before replace, editor=" + editor);
        CKEDITOR.replace(editor, {
            filebrowserImageUploadUrl: "/new/url/to/be/executed"
        });
        alert("After replace");
    })
});

第二个警报不仅不会执行,但是我尝试更新的配置选项仍然保留在 config.js中。

Not only does the second alert not execute, but the configuration option I'm trying to update remains as it appears in "config.js".

我认为我需要指定除 editor以外的其他内容 CKEDITOR.replace()语句的第一个参数,但是我不知道是什么。

I think I need to specify something other than "editor" as the first parameter for the CKEDITOR.replace() statement, but I don't know what.

推荐答案

经过更多研究,我发现可以在 CKEDITOR.inline 方法调用中设置配置选项。这是脚本的工作版本:

After more research, I discovered that I can set configuration options within the CKEDITOR.inline method call. Here's a working version of the script:

$(function () {
    $("textarea").each(function () {
        CKEDITOR.inline($(this)[0], {
            filebrowserImageUploadUrl: "/new/url/to/be/executed"
        });
    });
});

这篇关于CKEDITOR.inline之后如何使用CKEDITOR.replace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆