开发者

How to tell if tinyMCE has been initated?

I initiate the tinyMCE like this in multiple tabs of JQuery:Tab. But I find to init tinyMCE multiple times yields readonly text开发者_运维技巧 areas. Thus I wish to check if tinyMCE is already initated. Is there a method like isInitated() or something similarly convenient there?

tinyMCE.init({
    mode : "textareas",
    theme : "simple",
    width : "500",
    height : "300"
});


You can use tinymce.editors.length to see if there is already an editor instance initalized (tinymce.editors.length > 0).


I know this question is old, but...in case someone is still looking for the holy grail:

in tinymce 4, you can pass a callback to tinyMCE.init like so:

tinyMCE.init({
  //your regular parameters here...
  setup: function(editor) {
    editor.on('init', function() {
      //all your after init logics here.
    });
  }
});


You can add init_instance_callback to init() parameters. This callback will be invoked when the tinymce instance is already inited.


I am using tincyMCE 4.7.2
I tried the answer of @Thariama and it did not work for me, I guess because his answer is valid for the older versions of the tinyMCE.

here is what worked for me (again, according to the version you are working on, this could not be helpful for you)

if (tinymce.initialized === true)


To check if "tinyMCE" is set just use this:

if(typeof(tinyMCE) != "undefined") {}


Try this:

if (typeof(tinymce.activeEditor.contentDocument) !== "undefined") {
 // initialized
}


I found other solution for this.

Let's say that You've got element

<textarea id="tinymce0"></textarea>

Now let's say that You initialize it:

let config  = { selector : '#tinymce0'};
tinymce.init(config);

After that You can make this:

let tinmyMceInstance = tinymce.get('tinymce0');
if( tinmyMceInstance === null ){
  // Your code if not initialized
}

Keep in mind:

  • this works only with id, seems like using classname for get() won't work

Works in:

{
     releaseDate: "2019-05-09",
     majorVersion: "5",
     minorVersion: "0.5",
}

So it's probably: 5.5

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜