[英]Loading tinymce dynamically
当tinymce在头上,并在dom之前加载时,一切正常。 但是,如果我尝试使用ajax( jquery.getScript()
)加载javascript,它将无法正常工作。 当用户单击内容区域时,我正在启动tinymce,因此dom必须准备就绪。 我想在不更改tinymce代码的情况下且不在head标签中运行它,因为脚本约为65kb(压缩)。 我的代码如下所示:
window.tab_offers.show_edit = function() {
if (init == true) {
tinymce.execCommand('mceToggleEditor', false, 'offers-tab-content');
} else {
tinyMCE.init({
mode : "exact",
elements: "offers-tab-content",
language : window.PAGE_LANG,
theme : "advanced",
content_css: site_url('css/parim/tinymce.css'),
plugins : "autoresize",
width: $('#offers-tab-content').width() + 18,
theme_advanced_buttons1 : "cancelforecolor,backcolor,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator,undo,redo,separator,hr,removeformat,separator,charmap,separator,link,unlink",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : ""
});
init = true;
}
};
找到了问题。 Tinymce尝试从脚本标签中获取“ baseURL”,但是如果我将其动态加载,则没有匹配项。 它遍历页面上的每个脚本元素,并像这样检查它:/ /tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(n.src)
_ /tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(n.src)
。 所以我只是像这样重写了baseURL参数:tinyMCE.baseURL =“ http://mysite.com/path_to_tinymce/”; tinyMCE.init({...,...});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.