如何在更改选项时更新TinyMCE实例?

时间:2014-04-01 14:08:02

标签: javascript tinymce tinymce-4

我想在选项时刷新我的TinyMCE实例:{语言:" fr" }已更新。有没有办法应用新选项或重新加载实例?

我想用Javascript动态更改语言。

1 个答案:

答案 0 :(得分:4)

您需要致电

tinymce.execCommand('mceRemoveEditor', false, your_editor_id);

更改配置参数并调用

tinymce.execCommand('mceAddEditor', false, your_editor_id);

如果您不知道如何编辑您的tinymce参数,可以使用此调用

var init_obj = {
    plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu paste"
    ],
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    ....
};

new tinymce.Editor(id_of_your_textarea_to_become_an_editor, init_obj, tinymce.EditorManager).render();