PDA

View Full Version : Event definition



bkraut
7 Feb 2010, 3:50 PM
Hi,

I'd like to trigger an event on keyup on TextField.
This is my code in ext-overrides.js:



Ext.form.TextField.on (
'keyup', function(field, event) {
if (field.isDirty()) {
alert('Test');
}
}
);


I think the code is correct, but I get an exception:

Ext.form.TextField.on is not a function

in documentation on is defined on a Ext.form.TextField.

Is there any mistake in my code?

evant
7 Feb 2010, 3:59 PM
Ext.form.TextField is a class, not an instance, so you can't call any methods on it.

bkraut
7 Feb 2010, 5:53 PM
I thought so. So how can I define that all TextFields in the system change color if the value changed from the originalValue.

I'd like to define this just in one place.

evant
7 Feb 2010, 6:01 PM
Either:

a) Extend TextField and use that class
b) Override a method (probably initComponent) to bind any events you want

mystix
8 Feb 2010, 11:26 AM
or you could use @animal's Observable.observeClass() static method:
83015

bkraut
8 Feb 2010, 1:09 PM
Thanks to both. I'll try with Observable, as TextField is also superclass of ComboBox, TextArea etc. So I would need to subclass all of those classes.