My favorites | Sign in
Project Logo
                
Search
for
Updated Jun 18, 2009 by haineault
DelayedObserver  

jquery.delayedobserver.js

Author Copyright (c) 2007-2008 Maxime Haineault (haineault.com)
License MIT License

A delayed observer, useful for handling user inputs to avoid calling the callback function too often.

Autocomplete fields is a common situation where this mechanism is useful. You must post pone the AJAX call until the user stops typing to prevent fast typers to fire too much requests to the server and most likely hang the browser.

Example

<input type="text" id="autocomplete" />
$('#autocomplete').delayedObserver(function(value, autocompleteObject) {
    // AJAX call
});

Tested browsers


Comment by sathia.musso, Jan 21, 2009

can you please provide an example more clear? i can't get it working it returns $obj.data("callback").apply is not a function

where am I wrong?

thanks!

Comment by andrew.flanagan, Apr 15, 2009

The parameters are backwards... should be callback then delay...

Comment by haineault, Jun 18, 2009

@andrew.flanagan:

Sorry I forgot to update this doc for a while, it's fixed.


Sign in to add a comment
Hosted by Google Code