javascript and extJs - scope question
- by ben
Hi guys,
I got a little scope related problem with some js code, maybe somebody can explain to me what I'm making wrong:
I'm using extJs and got this snippet:
Ext.onReady(function(){
// Form for filter selection
var formFilter = new Ext.FormPanel({
// ...
items: [
cbGroup = new Ext.form.ComboBox({
fieldLabel: 'Group',
store: dsGroups,
displayField: 'name',
valueField: 'number',
emptyText : '- Please choose a group -',
listeners:{
'select': function() {
alert(cbGroup.selectedIndex +' '+this.selectedIndex);
}
}
})
]
});
});
The problem:
When I access the combobox over 'this' within the listener function, I get the correct result for the selectIndex property.
When I access the combobox over it's var name, I allways get the result '-1'.
Thank a lot for your help!