2011-05-12 54 views
3

我正在關注http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php上的教程,但需要添加多個自定義按鈕。TinyMCE添加多個自定義工具欄按鈕

這裏是我加入一個按鈕塊,但我需要添加多個按鈕,不知道怎麼

setup : function(fn) { 
    // Add a custom button 
    fn.addButton('firstname', { 
     title : 'Member First Name', 
     image : 'resources/scripts/tiny_mce/themes/advanced/img/firstname.gif', 
     onclick : function() { 
      // Add you own code to execute something on click 
      fn.focus(); 
      fn.selection.setContent('{firstname}'); 
     } 
    }); 
} 

感謝您的幫助

回答

6

只需撥打fn.addButton多次:

setup : function(fn) { 
    // Add a custom button 
    fn.addButton('firstname', { 
     title : 'Member First Name', 
     image : 'resources/scripts/tiny_mce/themes/advanced/img/firstname.gif', 
     onclick : function() { 
      // Add you own code to execute something on click 
      fn.focus(); 
      fn.selection.setContent('{firstname}'); 
     } 
    }); 
    fn.addButton('lastname', { 
     title : 'Member Last Name', 
     image : 'resources/scripts/tiny_mce/themes/advanced/img/lastname.gif', 
     onclick : function() { 
      // Add you own code to execute something on click 
      fn.focus(); 
      fn.selection.setContent('{lastname}'); 
     } 
    }); 
} 
+0

+1是的,這個答案很簡單,但它是正確的方式 – Thariama 2011-05-13 08:30:37

+0

非常感謝莫爾博士, 我在想的東西比較困難。你的回答幫了我很多! – drhoo 2011-05-13 11:04:26

相關問題