Perform action after TinyMCE rendered in DOM

雨燕双飞 提交于 2019-12-10 20:24:28

问题


I'm using TinyMCE 4 and setting it up as follows:

tinyMCE.init({
            mode : "specific_textareas",
            editor_selector : "basicTinyMCE",
            theme : "modern",
            readonly : false,
            ...});

I want to call a function after it has been rendered in the DOM.

I came across this and tried:

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

I get the following error:

SCRIPT5007: Unable to get property 'add' of undefined or null reference

Any ideas if this is the correct way to achieve what I want? And if so, why is the error appearing?


回答1:


You've got two options:

  1. Use configuration init_instance_callback http://www.tinymce.com/wiki.php/Configuration:init_instance_callback
  2. Use new way to add callbacks

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



来源:https://stackoverflow.com/questions/23522824/perform-action-after-tinymce-rendered-in-dom

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