我正在使用 ExtJS 4.0.7,是 Ext 的新手,并且正在使用新的 MVC 架构。我有一个 RadioGroup,在更改后,我想用它来显示更多 UI 元素。问题是,RadioGroup 的 change 事件触发了两次。我假设这是因为两个 Radios 都会触发一个事件以改变它们的值。
有没有办法监听 RadioGroup 或同名的 Radios 的更改,它只会触发一次?根据我使用 jQuery 和 Flex 的经验,我希望 RadioGroup 只触发一次。
这是我认为的 RadioGroup 代码:
items: [{
xtype: 'radiogroup',
id: 'WheatChoice',
padding: '',
layout: {
padding: '-3 0 4 0',
type: 'hbox'
},
fieldLabel: 'Choose Model',
labelPad: 5,
labelWidth: 80,
allowBlank: false,
columns: 1,
flex: 1,
anchor: '60%',
items: [
{ xtype: 'radiofield', id: 'SpringWheat', padding: '2 10 0 0', fieldLabel: '',
boxLabel: 'Spring', name: 'wheat-selection', inputValue: '0', flex: 1 },
{ xtype: 'radiofield', id: 'WinterWheat', padding: '2 0 0 0', fieldLabel: '',
boxLabel: 'Winter', name: 'wheat-selection', inputValue: '1', checked: true, flex: 1 }
]
}]
这是我的控制器中的相关代码:
init: function() {
this.control({
'#WheatChoice': {
change: this.onWheatChange
}
});
},
onWheatChange: function(field, newVal, oldVal) {
//this fires twice
console.log('wheat change');
}