PDA

View Full Version : How to detect when someone clears a textfield?



Nicodemuz
18 Feb 2011, 12:24 AM
I noticed there is a useClearIcon option for TextField. When the user presses the clear icon, is there any way to detect this event?

jay@moduscreate.com
18 Feb 2011, 5:40 AM
Since there is no "clear" event, you'll simply have to override the textfield method.



// put this *just after* sencha-touch JS
Ext.form.TextField.override({
// @private
onClearIconTap: function() {
if (!this.disabled) {
this.setValue('');
this.fireEvent('clear');
}
}
});



Now your code can setup an event listener.

pmarsilio
21 Aug 2011, 4:58 PM
Hi JGarcia,

I am trying to use your code but no luck so far. Where exactly should I place it?
Thanks,