将数据添加到TinyMCE中的自定义菜单按钮

问题描述:

如何将数据添加或关联到TinyMCE中的自定义菜单按钮?我的代码是这样的:将数据添加到TinyMCE中的自定义菜单按钮

tinyMCE.init({ 
     selector: 'textarea', 
     toolbar: " example", 
     setup: function (ed) {         
      ed.addButton('example', { 
       type: 'menubutton', 
       title: 'Insert Latest Newsletter Link', 
       icon: false, 
       text: 'Insert Latest Newsletter Link', 
       menu: [{text: "Insert Link", onclick: function() { 
        //this is where i want to retrieve data that 
        //i associated with my button 
       } }] 
      }); 
     } 

menu:[[object1],[object2],[object3]] 

显示object1,Object2的,object3在自定义按钮菜单

的解决方案是通过在菜单对象使用的 '价值' 等:

editor.addButton('gavickpro_tc_button', { 
    title: 'My test button', 
    type: 'menubutton', 
    icon: 'icon gavickpro-own-icon', 
    menu: [ 
     { 
      text: 'Menu item I', 
      value: 'Text from menu item I', 
      onclick: function() { 
       editor.insertContent(this.value()); 
      } 
     } 
    ] 
});