Categories | Question details Back To List | ||
Add event to specific button This is my code. <script> var toolbar = new dhtmlXToolbarObject('toolbar'); toolbar.attachEvent("onClick", function(id){ alert("Button "+id+" was clicked"); }); toolbar.setIconsPath("/assets/codebase/imgs/toolbar-icons/"); toolbar.addButton('new',0,'New','new.png','new.png'); toolbar.setItemToolTip("new", "New"); toolbar.enableItem('new'); toolbar.addButton('save',1,'Save','save.gif','save.gif'); toolbar.enableItem('save'); toolbar.addButton('refresh',2,'Refresh','reload.png','reload.png'); toolbar.enableItem('refresh'); toolbar.addSeparator('sep0',3); toolbar.addButton('preview',4,'Preview','publish_16x16.png','publish_16x16.png'); toolbar.enableItem('preview'); toolbar.addButton('print',5,'Print','print_g.png','print_g.png'); toolbar.enableItem('print'); toolbar.addSeparator('sep1',6); toolbar.addButton('delete',7,'Delete','delete.png','delete.png'); toolbar.enableItem('delete'); </script> How do I target the eventhandler to fire from just on a specific button. I Have tried just about everything I know, and either the toolbar disappears or it does not work. Answer posted by Alex (support) on Jul 17, 2009 01:40 Hello, you can check the item id before calling function. In this case it will be called only for a certain item. For example: toolbar.attachEvent("onClick", function(id){ if(id =='delete') alert("Button "+id+" was clicked"); |