tinyMCE is an object in WordPress but “tinyMCE.init is not a function”

I’m trying to add tinyMCE to a form field in WordPress. The form itself is generated by a plugin (JobRoller). The site already has a template and child templates that I was told I should not touch. My solution was to create a simple plugin that enqueues a JavaScript with both tinyMCE CDN and the code below.

The code below is all the JavaScript I’m adding.

Read More
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
    alert('b');
    tinyMCE.init({
        selector: 'textarea',
        plugins: 'textcolor link paste',
        height: 300,
        menubar: false,
        toolbar: [
          'bold italic underline strikethrough subscript superscript bullist numlist alignleft aligncenter alignright alignjustify link unlink',
          'formatselect forecolor copy cut paste pastetext removeformat indent outdent undo redo'
        ]
    });
}

When I run, I get the “b” from alert('b'); but also get this message:

Uncaught TypeError: tinyMCE.init is not a function

If type of tinyMCE is an object and execCommand is a function, how is it possible that tinyMCE.init is not a function?

Any help would be highly appreciated.

Related posts

1 comment

  1. The problem was caused by conflict with a CKEditor plugin that the site owner had installed. Deactivating the plugin solved the issue.

Comments are closed.