Javascript 在document.ready()上加载TinyMce JS文件不使用$.getScript
我试着这样做Javascript 在document.ready()上加载TinyMce JS文件不使用$.getScript,javascript,jquery,callback,tinymce,getscript,Javascript,Jquery,Callback,Tinymce,Getscript,我试着这样做 $.getScript('js/tiny_mce/tiny_mce.js',function(){ recargar_tiny(); }); 关于document.ready() firebug上的日志:.js加载正常,无错误 但似乎recargar_tiny()是: function recargar_tiny(){ tinyMCE.init({ mode : "textareas", them
$.getScript('js/tiny_mce/tiny_mce.js',function(){
recargar_tiny();
});
关于document.ready()
firebug上的日志:.js加载正常,无错误
但似乎recargar_tiny()是:
function recargar_tiny(){
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,inlinepopups",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,table,removeformat,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
editor_deselector : "no_tiny",
content_css : "/js/tinymce/examples/css/content.css",
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],
formats : {
alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
bold : {inline : 'span', 'classes' : 'bold'},
italic : {inline : 'span', 'classes' : 'italic'},
underline : {inline : 'span', 'classes' : 'underline', exact : true},
strikethrough : {inline : 'del'},
customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
}
});
}
似乎没有加载WYSWYG编辑器。如果我“正常”加载它,它就会工作
我做错了什么
-编辑-
甚至尝试了一个新功能:
function recargar_tiny_now(){
$.getScript('/js/tiny_mce/tiny_mce.js',function(){
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "inlinepopups",
media_strict: false,
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,forecolor,image,link,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,removeformat,|,bullist,numlist,|,outdent,indent",
heme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
editor_deselector : "no_tiny",
// Example content CSS (should be your site CSS)
content_css : "/js/tinymce/examples/css/content.css",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Blue text', inline : 'span', styles : {color : '#006'}},
{title : 'Blue header', block : 'h1', styles : {color : '#006'}},
{title : 'Codigo fuente', inline : 'code', classes : 'prettyprint', exact: true}
],
formats : {
alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
bold : {inline : 'span', 'classes' : 'bold'},
italic : {inline : 'span', 'classes' : 'italic'},
underline : {inline : 'span', 'classes' : 'underline', exact : true},
strikethrough : {inline : 'del'},
customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
}
});
});
}
作为回调,最终得到了一些东西,tiny不起作用,但我使用Firebug:
谢谢 尝试以下操作:函数recargar_tiny(){console.log(tinyMCE)}netbeans gets me syntax error您可以发布一个或一个来演示问题吗?@Toni Michel Caubet:console.log将与firebug一起使用在回调中定义recargar_tiny()函数,因为我们看不到任何其他代码,这将有助于消除出现范围问题的可能性。