I have a website with a form that uses TinyMCE; Regardless, I use jQuery. When I download a form from an intermediate server on Firefox 3 (MacOS X, Linux), TinyMCE does not finish the download. There is an error in the Firefox console stating that t.getBody() returned null . t.getBody() , as I understand it from TinyMCE docs, is a function that returns a document body element for checking some functions. The problem does not occur when I use Safari, and also when I use Firefox with the same site that works with localhost.
The original, JavaScript-related code failure looked like this:
<script type="text/javascript" src="http://static.alfa.foo.pl/json2.js"></script> <script type="text/javascript" src="http://static.alfa.foo.pl/jquery.js"></script> <script type="text/javascript" src="http://static.alfa.foo.pl/jquery.ui.js"></script> <script type="text/javascript" src="http://static.alfa.foo.pl/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ mode:"specific_textareas", editor_selector:"mce", theme:"simple", language:"pl" }); </script> <script type="text/javascript" src="http://static.alfa.foo.pl/jquery.jeditable.js"></script> <script type="text/javascript" src="http://static.alfa.foo.pl/jquery.tinymce.js"></script> <script type="text/javascript" charset="utf-8" src="http://static.alfa.foo.pl/foo.js"></script> <script type="text/javascript"> $(document).ready(function(){ /* jQuery initialization */ }); </script>
I tried changing the loading order of the script by moving the tinyMCE.init() call to the <script/> , $(document).ready() call-before, after . . tinyMCE.init() $(document).ready() , - , init. tinyMCE.init() call to the <script/> , $(document).ready() call-before, after . . tinyMCE.init() $(document).ready() , - , init.
Then, after working a bit on using TinyMCE with jQuery, I changed the call to tinyMCE.init() to:
tinyMCE.init({ mode:"none", theme:"simple", language:"pl" });
and the following jQuery call was added to the $(document).ready() handler:
$(".mce").each( function(i) { tinyMCE.execCommand("mceAddControl",true,this.id); });
Still the same error. But here, when things begin to look like real voodoo, when I added alert (i); before calling tinyMCE.execCommand (), warnings were given and the TinyMCE text fields were correctly initialized. I figured it might be a delay caused by the user waiting for the warning to be rejected, so I entered a second delay, changing the call, still in the $ (document) .ready () handler, as follows:
setTimeout ('$ (". mce"). each (function (i) {tinyMCE.execCommand ("mceAddControl", true, this.id);});', 1000);
When the timeout occurs, the TinyMCE text fields will be correctly initialized, but this will concern the real problem. The problem looks like an obvious race condition (especially when I consider that in the same browser, but when the server is on the local host, the problem does not occur). But is JavaScript not executing once? Can someone please enlighten me about what is happening here, where is the real problem, and what can I do to really fix this?