Hi!
Thanks.
Viewcontroller: repeatedly call the same method with different reference
In the following example I have one method (onChange) I want to call on several elements (textfield).
Issue: being different references, I have to create three different onChange methods, one for each textfield with different references, or is there another way to call the same method, for example, passing in listeners as parameters the diferents reference?
Code:
Ext.define('MyApp.view.foo.Foo', {
extend: 'Ext.form.Panel',
xtype: 'foo',
controller: 'foo',
items: [{
xtype: 'textfield',
fieldLabel: 'Bar1',
listeners: {
change: 'onChange'
}
},{
xtype: 'textfield',
fieldLabel: 'Bar2',
listeners: {
change: 'onChange'
}
},{
xtype: 'textfield',
fieldLabel: 'Bar3',
listeners: {
change: 'onChange'
}
},{
xtype: 'combobox',
fieldLabel: 'combo1',
reference: 'fooRef1'
},{
xtype: 'combobox',
fieldLabel: 'combo2',
reference: 'fooRef2'
},{
xtype: 'combobox',
fieldLabel: 'combo3',
reference: 'fooRef3'
}]
});
Ext.define('MyApp.view.foo.FooController', {
extend: 'Ext.app.ViewController',
alias: 'controller.foo',
onChange: function( field,newValue, eOpts) {
var field = this.lookupReference('fooRef');
if(!Ext.isEmpty(newValue)) {
field.setHidden(false);
}
else {
field.setHidden(true);
}
}
}
});
Thanks.
Viewcontroller: repeatedly call the same method with different reference
Aucun commentaire:
Enregistrer un commentaire