I'm trying to start tinyMCE after loading the library by createElement but it doesn't work!
Maybe I am forgetting something, I don't know...
Basically the function is:
scriptLoad = false;
function tinyInit() {
if (!scriptLoad) {
var s = document.createElement('script');
s.src = '/tiny_mce/tiny_mce.js';
s.type = 'text/javascript';
document.body.appendChild(s);
scriptLoad = true;
}
// wait until load
if (typeof tinyMCE == 'undefined') {
window.setTimeout(function() {
tinyInit();
}, 120);
}
else {
// alright! bring it to me
tinyMCE.init({
mode: 'textareas',
theme: 'simple'
});
}
}
I've tested with Firebug and the library exists. Changing the value of tinyMCE.baseURL does not work because it has the right value.
I apreciate any help!
Thanks
Resolved!
I was looking at the source code and saw that init creates two default properties: theme and language. I don't know why they are not extending our settings when the library is loaded by createElement or AJAX. So the solution is set these two properties on init:
scriptLoad = false;
function tinyInit() {
if (!scriptLoad) {
var s = document.createElement('script');
s.src = '/tiny_mce/tiny_mce.js';
s.type = 'text/javascript';
document.body.appendChild(s);
scriptLoad = true;
}
// wait until load
if (typeof tinyMCE == 'undefined') {
window.setTimeout(function() {
tinyInit();
}, 120);
}
else {
// alright! bring it to me
tinyMCE.init({
mode: 'textareas',
theme: 'simple',
language: 'en'
});
}
}
You want to load the tinyMCE compressor version in this fashion, not the regular tiny_mce.js file.
Read here for more details: http://www.tinymce.com/wiki.php/Compressors
Basically the reason why it won't work as you have tried is because it needs to load certain javascript files in various orders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With