I am using Jquery's Geocomplete library. I want to delay for 1 second before we hit on google for address complete.
I have written code which will do the delay work:
var timeout = null;
function doDelayedSearch(val) {
if (val.length >= 3) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
console.log("Called Yay ==> " + val);
}, 1000);
}else{
return false;
}
}
I need the callback where I can use the above code.
Something like:
$('#user_location').geocomplete()
.bind("geocode:beforegeocomelete_search", function(event, results){
doDelayedSearch(val);
});