How to use CKEDITOR.replace after CKEDITOR.inline

会有一股神秘感。 提交于 2019-12-20 03:21:49

问题


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.

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.

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");
    })
});

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

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.


回答1:


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"
        });
    });
});


来源:https://stackoverflow.com/questions/26429725/how-to-use-ckeditor-replace-after-ckeditor-inline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!