PDA

View Full Version : how to sign up event handlers properly



Bogdan0x400
16 Feb 2011, 2:05 AM
How do you assign an event handler to an Ext control properly when you extend a control and add child controls to it?

Ext.extend(mynamespace.SomeDetails, Ext.FormPanel, {
layout: 'tableform',
layoutConfig: {
columns: 2
},
defaults: {
anchor: '100%',
xtype: 'textfield'
},
initComponent: function () {
var config = {};
config.items = [
{
name: 'ClientName',
xtype: 'displayfield',
fieldLabel: 'Client name',
click:function(){alert("click");}//this doesn't work
}
];
Ext.apply(this, Ext.apply(this.initialConfig, config));
mynamespace.SomeDetails.superclass.initComponent.call(this);
},
afterRender: function () {
mynamespace.SomeDetails.superclass.afterRender.call(this);
}
});

Bogdan0x400
16 Feb 2011, 3:06 AM
listeners:
{
click:function(){alert("click");}
}
And that worked.