The following method:
Init: function (selector, settings)
{
setTimeout(function()
{
var s =
{
width: '100%',
script_url: '/Content/Scripts/tiny_mce/tiny_mce.js',
theme: "advanced",
plugins: "autolink,lists,pagebreak,style,layer,table,paste,directionality,noneditable,visualchars,xhtmlxtras,template",
theme_advanced_buttons1: "fontselect,fontsizeselect,|,bold,italic,underline,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
theme_advanced_buttons4: "",
theme_advanced_more_colors: false,
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "none",
theme_advanced_resizing: false,
convert_urls: !!$(selector).data("richEditor-ConvertUrls") // by default we don't convert urls
};
$.extend(s, settings);
$(selector).tinymce(s);
},0);
}
works on all browsers,
for some reason, I need the setTimeout(f,0) call for firefox, this method is called on an ajax partial load on MVC, without this call, the editor hangs on firefox and the page breaks (clicking on stuff results on exceptions most often than not). with the call, everything works perfectly.
I was wondering how I could avoid this setTimeout call (through some other workaround), and if that wasn’t an option I would like to know why.
I’m scared this might not be the cleanest solution for this case.
This is bound to be a timing issue.
Does anything else happen on DOMContentLoaded, maybe tinyMCE or another script also runs things on that event?
Or a script is loaded which executes a document.write()?
Probably executing this function on load makes the issues go away.
If that’s the case than you have to figure out whats happening at the time the problems occur, maybe do a profile session in Firebug.