Reputation: 505
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"
});
Upvotes: 15
Views: 30532
Reputation: 1
To do Thariama's solution in TinyMCE 6 onwards, you can make a check like this:
if (tinymce.Editor.length > 0) {
// your action here
}
Upvotes: -1
Reputation: 483
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:
get()
won't workWorks in:
{
releaseDate: "2019-05-09",
majorVersion: "5",
minorVersion: "0.5",
}
So it's probably: 5.5
Upvotes: 1
Reputation: 1463
Try this:
if (typeof(tinymce.activeEditor.contentDocument) !== "undefined") {
// initialized
}
Upvotes: 2
Reputation: 486
To check if "tinyMCE" is set just use this:
if(typeof(tinyMCE) != "undefined") {}
Upvotes: 6
Reputation: 19511
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)
Upvotes: 2
Reputation: 2232
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.
});
}
});
Upvotes: 21
Reputation: 1847
You can add init_instance_callback
to init()
parameters. This callback will be invoked when the tinymce instance is already inited.
Upvotes: 4
Reputation: 50840
You can use tinymce.editors.length
to see if there is already an editor instance initalized (tinymce.editors.length > 0
).
Upvotes: 27