PDA

View Full Version : toggleGroup Listener?



the_skua
10 Feb 2012, 11:22 AM
Is there a listener for a whole set of Buttons with a toggleGroup, or do I have to listen to each button?

View

{ xtype: 'container',
id: 'buttonGroupContainer',
columnWidth: 0.52,
items: [
{
xtype: 'button',
id: 'hrs0',
text: '0',
toggleGroup: 'forecastButtons',
pressed: 'true'
},
{
xtype: 'button',
id: 'hrs24',
text: 24,
toggleGroup: 'forecastButtons'
},
{
xtype: 'button',
id: 'hrs48',
text: 48,
toggleGroup: 'forecastButtons'
},
{
xtype: 'button',
id: 'hrs72',
text: 72,
toggleGroup: 'forecastButtons'
}
]
}

mitchellsimoens
10 Feb 2012, 11:32 AM
If you aren't using MVC then you would have to listen in each button.

the_skua
10 Feb 2012, 11:34 AM
I am using MVC. Here's my controller block. I just listen to all buttons at once, which catches two events. Is there a way to only catch one event for the whole group? A different selector maybe?


init: function() {
console.log('forecast init');

this.control({
'#buttonGroupContainer button': {
toggle: this.forecastToggle
}
})
},

forecastToggle: function(btn, pressed) {
if(pressed) {
//fire event for btn id
}
}

mitchellsimoens
10 Feb 2012, 11:35 AM
The based on the componentquery you should be able to have the listener listen for each button