PDA

View Full Version : Delegate listener to ExtJS component inside view



sfpc2770
22 Jan 2014, 7:35 AM
In Touch, the delegate option on addListener uses Ext.ComponentQuery to allow you to add a listener to, say, all buttons in "this" view without dealing with the dom .el level.

In ExtJS, it acts differently. And yet the controller selectors work the same. Is there a way to add a single listener to all buttons in a panel similar to how the controller does it without explicitly finding and adding the listener to each one?

In touch, the following would call filterChanged any time any segmented button (there are several, dynamically added) was toggled in the titlebar.


titlebar.on({ toggle: function (seg,button,pressed){ me.filterChanged(); }, delegate: 'segmentedbutton', scope: me });
Thanks,
-Sean

mitchellsimoens
6 Feb 2014, 11:38 AM
Unfortunately Ext JS doesn't have this ability to use the delegate event option. You would just have to settle with a controller listener instead.

sfpc2770
6 Feb 2014, 1:12 PM
That's too bad. I found it very useful in Touch to simplify the events coming from a view. Oh well, time to write some custom code and add it back in anyway... :-)