Daemach schrieb:
> I have a form with which I want to do ajax updates as they type.  If they
> stop typing for more than 2 seconds it should update the field.  If the
> field blurs before the 2 seconds are up it should update the field.  
>
> I have the ajax side of it worked out, and currently the updates work
> properly when the field blurs.  I just need some ideas on how to write the
> timer function for the keypresses and how it integrates with the blur
> function so the function doesn't get called twice and so there are no memory
> leaks from timers set then abandoned because the blur event got to it first.
>
> I'm going for elegance here :)  I could write an outside function that gets
> called from both event handlers but that seems cheezy.  There must be a way
> to do this with an anonymous function...
>   
Well, sounds like you need to start a timeout on keyup/press and clear 
that with the blur function, in case it is still running. So you need 
the timeout id and a updated-flag.

Hope that helps.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to