私は ExtJS 4.0.7 を使用しており、Ext は初めてで、新しい MVC アーキテクチャを使用しています。変更時に、より多くの UI 要素を表示するために使用したい RadioGroup があります。問題は、RadioGroup に対して change イベントが 2 回発生することです。これは、両方のラジオが値を変更するためのイベントを発生させるためだと思います。
一度だけ起動する同じ名前の RadioGroup または Radios への変更をリッスンする方法はありますか? jQuery と Flex での私の経験では、RadioGroup は 1 回だけ起動すると予想していました。
私の見解では 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');
}