0

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);
});
Sachin Prasad
  • 5,365
  • 12
  • 54
  • 101
  • On the same page above you have the list of Events you can use. What is the problem than? `"geocode:result"` `"geocode:error"` `"geocode:multiple"` `"geocode:dragged"` `"geocode:click"` and `"geocode:zoom"` – skobaljic May 01 '19 at 12:45
  • @skobaljic None of them fit in my requirement. I want to stop auto request to Google for address. I want to customise it. – Sachin Prasad May 01 '19 at 13:10
  • Than insert fake field for input and hide the real field? Once you like the input than request Google for address. In docs we can see you can call the find method this way `$("#user_location").geocomplete("find", "NYC");` – skobaljic May 02 '19 at 11:00

0 Answers0