This support forum belongs to the AlloyUI State Interaction Gallery Module.
AlloyUI State Interaction has a bug tracker here: http://issues.liferay.com/browse/AUI
| Page 1 of 1 | [ 5 posts ] |
|
Is there a way to handle clicks on the toolbar thru one onMenuClick function?
It works when I add a handler to every label, would be nicer if it could be configured once and pass the id or label to the onMenuClick function. Code: AUI().ready('aui-toolbar', function(A) { function onMenuClick(item) { // handle toolbar clicks alert(item); }; var component = new A.Toolbar( { activeState: true, children: [ {label: 'Add', icon: 'plus',handler:function(){onMenuClick('add');}}, {label: 'Remove', icon: 'minus'}, {label: 'Config', icon: 'gear'} ] }).render('#toolbar'); }); |
Nate CavanaughYUI Contributor
|
Hi there,
Nate Cavanaugh
You can add an "after" listener on the toolbar that will attach a listener after a child is added. If you dynamically add new buttons they'll also get the handler as well. Code: function onMenuClick(item) { // handle toolbar clicks alert(item); }; var component = new A.Toolbar( { activeState: true, after: { addChild: function(event) { event.child.set('handler', function(event) { onMenuClick(this.get('id')); }); } }, children: [ {label: 'Add', icon: 'plus'}, {label: 'Remove', icon: 'minus'}, {label: 'Config', icon: 'gear'} ] } ).render('#demo1'); You can set the level information you wish to pass to onMenuClick, even passing the event object itself and referring to the button via: event.currentTarget. Hopefully that helps, but let me know if you have any other questions. Thanks, |
|
Thanks, this is what I was looking for.
Greetings Matthieu. |
|
Its working for the complete working example see:
http://www.digirent.nl/psmyui/vb/tb1.html Thanks. Greetings Matthieu Last edited by mc_hendriks on Fri Oct 08, 2010 3:41 am, edited 1 time in total. |
| Page 1 of 1 | [ 5 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group