PDA

View Full Version : extending an element



raj_plays
22 Nov 2013, 3:33 AM
Hi,
I need to extend a Textfield. In the subclass, I want to have a mouseover event.
And when this event is fired, I want to execute a function.
Users can add their own listener implementation but that function should always get called.
Possible?

I tried the following code. Doesn't work :(. Please help.


Ext.form.Textfield_Image = Ext.extend(Ext.form.Textfield, {
url: '',
readOnly: true,
initComponent: function () {
Ext.form.Textfield_Image.superclass.initComponent.call(this);
},
initEvents: function () {
Ext.form.TextField.superclass.initEvents.call(this);
this.mon(this.el, {
scope: this,
mouseover: this.onMouseOver
});
},
onMouseOver: function (e) {
func();
}
});


Ext.reg('textfield_image', Ext.form.Textfield_Image);

mitchellsimoens
3 Dec 2013, 12:48 PM
initComponent is too soon, the textfield is not rendered yet. Use afterRender method instead.