2
当我尝试创建小插件以允许我在网站上的所有textareas上打开和关闭所见即所得时,会出现问题。TinyMCE + jQuery +自定义插件= tinymce未定义?
//$('form.default textarea').each(function(){
// console.log($('<a href="#">Enable WYSIWYG editor</a>').insertAfter('form.default textarea').prev('textarea.wysiwyg').tinymce().hide());
//});
完整的(有点简化)的代码如下所示:
$('textarea.wysiwyg').tinymce({
skin : 'cirkuit',
theme : 'advanced',
plugins : 'pagebreak,style,layer,advlink,inlinepopups,contextmenu,paste,directionality,noneditable,nonbreaking,xhtmlxtras,template',
// Theme options
theme_advanced_buttons1 : 'formatselect,fontsizeselect,forecolor,|,bold,italic,strikethrough,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,image,|,code,paste,pastetext,pasteword,removeformat,|,backcolor,|,underline,justifyfull,sup,|,outdent,indent,|,hr,charmap,|,undo,redo',
theme_advanced_buttons2 : '',
theme_advanced_buttons3 : '',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_statusbar_location: 'bottom',
theme_advanced_resizing : true,
theme_advanced_resize_horizontal : false,
height : 500,
theme_advanced_resizing_min_height : 500,
document_base_url : 'http://static.<?=$settings['system_host']?>/'
});
$('textarea.wysiwyg').each(function() {
$(this).tinymce().hide();
});
什么错误? FireBug说tinymce()在undefined;这个消息发生在每个()循环中。因此,tinymce()实际上已经初始化了。
我真的迷失了方向,可能会造成这种情况。