在DOM中呈现TinyMCE后执行操作

Tho*_*ley 3 tinymce

我正在使用TinyMCE 4并将其设置如下:

tinyMCE.init({
            mode : "specific_textareas",
            editor_selector : "basicTinyMCE",
            theme : "modern",
            readonly : false,
            ...});
Run Code Online (Sandbox Code Playgroud)

我希望在DOM中呈现它之后调用一个函数.

我遇到过这个并尝试过:

tinyMCE.init({
                mode : "specific_textareas",
                editor_selector : "basicTinyMCE",
                theme : "modern",
                readonly : false,
                setup : function(ed) {
                  ed.onPostRender.add(function(ed,cm) {
                    console.log('After render: ' + ed.id);
                  });
                }
              });
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

SCRIPT5007: Unable to get property 'add' of undefined or null reference
Run Code Online (Sandbox Code Playgroud)

任何想法,如果这是实现我想要的正确方法?如果是这样,为什么出现错误?

小智 6

你有两个选择:

  1. 使用配置init_instance_callback http://www.tinymce.com/wiki.php/Configuration:init_instance_callback
  2. 使用新方法添加回调

    ed.on('postRender',function(e){console.log('postRender');});