PDA

View Full Version : [solved] Onclick for DateField (or any component)



KJedi
8 Jun 2008, 7:57 AM
I need to change color of the date field when it is double clicked. Changing color is not a problem (add class and that's all), but how to catch double click event on the DateField?
Seems like components don't fire this event... How to solve this problem?

Any quick help will be highly appreciated!

Thanks beforehand!

KJedi
8 Jun 2008, 1:07 PM
I solved it!
Idea is to wait until component is rendered and then attach listener manually using Ext.EventManager:

this.Controls.Date = new Ext.form.DateField({
fieldLabel:config.Caption || 'unknown',
listeners:{
'change':{
fn:this.onDateChange,
scope:this
},
'render':{//add listener to the control after it renders
fn:function(){
Ext.EventManager.on(this.Controls.Date.el, 'dblclick', this.onColorChange, this);//here we attach listener for double click.
//It works like the same thing in YahooUI
},
scope:this
}
}
});

That's it! Very simple and will work for anything fine.