我正在使用ExtJS 4.0.7,是Ext新增的,并且正在使用新的MVC体系结构。我有一个RadioGroup,在更改时我想用它来显示更多的UI元素。问题是,更改事件为RadioGroup激发两次。我假设这是因为两个无线电台都会触发一个事件,让它们的值发生变化。ExtJS 4 RadioGroup更改事件两次触发
有没有一种方法可以侦听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');
}
确认([小提琴](http://jsfiddle.net/molecule/4sTQQ/))。看起来像一个错误。 – 2012-02-10 14:57:20
这不是一个解决方法。我只创建了bug的展示。 – 2012-02-10 15:30:03
对不起,我正在谈论我发布的东西。这是一种解决方法:将选择器更改为'#WheatChoice radio',并使用事件侦听器中的逻辑忽略任何不等于true的新值。 – 2012-02-10 15:37:30