Load tinymce on demand using jquery

This is my script:

$.ajaxSetup({async: false}); $.getScript('http://www.mydomain.com/dev/js/tinymce/tiny_mce.js', function(){ tinyMCE.init({ document_base_url : "http://www.mydomain.com/dev/js/tinymce/", [...], }); }); $.ajaxSetup({async: true}); 

It downloads tiny_mce.js success. But when init tinymce is in the callback, tinymce loads the following 2 scripts with the wrong path:

 http://www.mydomain.com/dev//langs/en.js http://www.mydomain.com/dev//themes/advanced/editor_template.js 

Even if I use document_base_url or not, tinymce still loads above the path.

+4
source share
2 answers

I also have this problem, after a working day I found a solution, just add this code before your tinymce.init() method:

  tinymce.dom.Event.domLoaded = true; 

it will work on my case, maybe it will help too.

see here in more detail: tiny mce cannot be enabled when dynamically loading js

+7
source

I solved the problem as written here: http://tinymce.moxiecode.com/forum/viewtopic.php?pid=23065#p23065

My script for dynamically loading tinyMCE via jQuery now:

 // JS_FOLDER = "http://mydomain.com/js" function initTinyMCE(JS_FOLDER, selector) { var path = JS_FOLDER + '/GlobalUI/tinymce'; if (selector == undefined) selector = 'mceEditor'; var initFunct = function() { tinyMCE.baseURL = path + '/jscripts/tiny_mce/'; // THE IMPORTANT LINE tinyMCE.init({ mode: "specific_textareas", editor_selector: selector, width : "700px", theme: "advanced", theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,forecolor,backcolor", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_buttons4 : "", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : path + "/css/custom_css.css" }); } if(typeof tinyMCE == "undefined") { $.getScript(path + '/jscripts/tiny_mce/tiny_mce_src.js', function() { initFunct(); }); } else { initFunct(); } 
+5
source

All Articles