In what context does the timer run?  Each field will have its own timer/ajax
function.  If I have multiple text fields, and people are typing and tabbing
through them quickly the updates still need to happen reliably.

Currently it works like this:

$(document).ready( function() { 
        $('[EMAIL PROTECTED]').each( function() {
                $(this).blur( function() {
                        $.AjaxCFC({url: "/namechangedtoprotecttheinnocent.cfc", 
method:
"updateAttendee", data:
{fid:this.id,field:this.id.split("_")[0],id:this.id.split("_")[1],value:this.value},
success: function(r){$('#'+r).css("backgroundColor","#ddFFdd");}});
                        $(this).css("backgroundColor","#FFdddd");
                });
        });
});     



Jörn Zaefferer wrote:
> 
> 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/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Gmail-style-updates-tf3269331.html#a9089663
Sent from the JQuery mailing list archive at Nabble.com.


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

Reply via email to