0

I'm using bootstrap-typeahead.js v2.0.3 to autocomplete an text input. I'm also using gravity form's Dynamic Population to add a value to the autocomplete text input. How can I trigger the autocomplete to look up data related to the dynamically populated value?

I've tried to add simple jQuery trigger functions, with no luck.

Here is a snippit of my autocomplete (typeahead) initialization:

$('.restaurant_name input').typeahead({
  source: function(typeahead, query) {
    var _this = this;
    return $.ajax({
      url: "/restaurants.json?q=" + query,
      success: function(data) { 
        return typeahead.process(data);
      }
    });
  }, onselect: function (obj) {
    if (obj.City != ''){
      $(".restaurant_city input").attr("value", obj.City);      
    }
    if (obj.State != ''){
      $(".hotel_state input").attr("value", obj.State);     
    }
    if (obj.Zip != ''){
      $(".hotel_zip input").attr("value", obj.Zip);     
    }
  },
  property: "LocationName1"
});

Any help would be much appreciated.

Thanks y'all!

jgillich
  • 71,459
  • 6
  • 57
  • 85
user2888697
  • 173
  • 3
  • 14

1 Answers1

0

Figured it out thanks to another post.

I just had to add:

$(".hotel_name input").typeahead('lookup').focus();
Community
  • 1
  • 1
user2888697
  • 173
  • 3
  • 14