My main goal is to get editor content when it changes and update a live preview. For this I need to add an event listener to the editor. BTW, I have two editor in the same page and the page is loaded via ajax.

Now back to my problem. I can't get to the instance of the tinyMCE editors. I can console.log() them but get empty result when I try to stringify them.

Below is the result of console.log(tinymce.editors).


So, whenever I try to access editors using tinymce.editors.contentleft, tinymce.editors['contentleft'], tinymce.get('contentleft') or tinymce.EditorManager.get('contentleft') in all these cases I get undefined or null

Working more then couple days on this. Would appreciate a proper direction soon.

1 Answer 1


If you wait for the SetupEditor event then you can access the editors:

add_action( 'admin_print_footer_scripts', function () {
    <script type="text/javascript">
    jQuery(function ($) {
        if (typeof tinymce !== 'undefined') {
            tinymce.on('SetupEditor', function (editor) {
                if (editor.id === 'contentLeft') {
                    // Could use new 'input' event instead.
                    editor.on('change keyup paste', function (event) {
                        console.log('content=%s', this.getContent());
} );
  • spot on! So, I guess I was running the script early?
    – Sisir
    Commented Jun 29, 2015 at 10:07
  • Yes! (tinymce takes several microseconds to setup each editor so the fact that yours is a secondary one probably exasperated the situation.)
    – bonger
    Commented Jun 29, 2015 at 10:22
  • 1
    ps: we should probably add a typeof tinymce != 'undefined' check, to avoid error on pages where tinymce isn't defined.
    – birgire
    Commented Aug 27, 2015 at 9:10
  • Good point @birgire ta, I'll update the answer...
    – bonger
    Commented Aug 27, 2015 at 10:02
  • I think function(editor) should be function(event) { var editor = event.editor; .. Commented Oct 6, 2018 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.