2013-11-01 193 views
0

我跟着一个问题位于here添加一个自定义下拉菜单到我的tinymce,但我不能得到它的工作。当我添加相关的代码在我tinyMCE.init,当我注册这个插件我碰到下面的错误在我的控制台自定义下拉菜单 - Tinymce

Uncaught TypeError: Object [object Object] has no method 'addMenuItem'

我的目标是有一个下拉菜单选择时将内容插入textarea的那个。此刻我正在使用按钮来做这件事,但他们开始堆积起来,看起来非常混乱。我宁愿有一个下拉,所以我可以轻松地添加到它,而没有太多的按钮分散在这个地方。

我确定我已经在我的头文件中包含了相关文件,但也许这就是错误的原因吧?

我的代码是位于下方

var myListItems = ['Item1','Item2']; 
tinymce.PluginManager.add('myNewPluginName', function(editor) { 
var menuItems = []; 
tinymce.each(myListItems, function(myListItemName) { 
    menuItems.push({ 
     text: myListItemName, 
     onclick: function() { 
      editor.insertContent(myListItemName); 
     } 
    }); 
}); 

editor.addMenuItem('insertValueOfMyNewDropdown', { 
    icon: 'date', 
    text: 'Do something with this new dropdown', 
    menu: menuItems, 
    context: 'insert' 
    }); 
}); 
tinyMCE.init({ 
    theme : "advanced", 
    mode: "exact", 
    plugins: "table,myNewPluginName", 
    elements : "elm1,elm2,elm3,elm4,elm5,elm6", 
    theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px", 
    font_size_style_values: "12px,13px,14px,16px,18px,20px", 
    theme_advanced_toolbar_location : "top", 
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator," 
    + "justifyleft,justifycenter,justifyright,justifyfull,formatselect," 
    + "bullist,numlist,outdent,indent,seperator,fontselect,fontsizeselect", 
    theme_advanced_buttons2 : "tablecontrols", 
    height:"500px", 
    width:"100%", 
    file_browser_callback : 'myFileBrowser'  
    }); 

任何帮助将不胜感激!

回答

0

我更新了我的TinyMCE,并按照TinyMCE网站上的说明操作,并且完美运行

相关问题