Hybrid View
-
12 Nov 2007 8:47 PM #1
How to add the onkeyup event to a TextField object?
How to add the onkeyup event to a TextField object?
Hi,
I've tried the following, but the onkeyup event doesn't seem to fire for the TextField object?
Any pointers appreciated.Code:new Ext.form.TextField({ emptyText:'insert name', listeners: { 'onkeyup': function(obj) { alert('test fire'); } } }),Last edited by JeffHowden; 12 Nov 2007 at 9:25 PM. Reason: please use CODE tags.
-
12 Nov 2007 9:33 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Forest Grove, OR
- Posts
- 1,038
- Vote Rating
- 0
Unfortunately, the TextField class does not expose the onkeydown, onkeypress, or onkeyup events from the underlying input. Fortunately, I have an override that'll expose them for you.
http://extjs.com/forum/showthread.php?t=17532Jeff Howden
Ext JS - Support Team Volunteer
jeff@extjs.com
Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.
Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.
-
12 Nov 2007 9:59 PM #3
thanks Jeff.
It's worked (the keyup gets fired). Maybe my understanding of event buffering is wrong (I'm a newbie), but event buffering doesn't seem to work?
After the buffering delay period, the event gets fired in consecutive succession (if I enter 5 characters during the event buffering, the alert gets displayed 5 times)
Code:<snip> new Ext.form.TextField({ emptyText:'insert name', listeners: { 'keyup': { fn: function(obj) { alert('test'); }, delay: 1000 } } }), <snip>
-
12 Nov 2007 11:00 PM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Forest Grove, OR
- Posts
- 1,038
- Vote Rating
- 0
Maybe what you want is the buffer property of the config, instead of the delay.
Jeff Howden
Ext JS - Support Team Volunteer
jeff@extjs.com
Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.
Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.
-
12 Nov 2007 11:07 PM #5
As Jeff suggested, delay merely adds an extra time period before the event is fired. From the docs:
* delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.
* buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.
-
13 Nov 2007 3:28 AM #6
Thanks heaps guys - that did it!
Glad this forum exists!


Reply With Quote
