I have two input fields and I want to use the same typeahead code in both the input control. The only difference is that the suggestion should come below that specific control.
$('input.typeahead').typeahead({
source: function (query, result){
var data = 'data=' + query;
if ((obj.user_latitude() !== 0) && (obj.user_longitude() !== 0)){
data = data +"&radius=50000&location=" + obj.user_latitude() + "," + obj.user_longitude();
}
console.log(data);
if (ajaxRequest) { // if any previous ajaxRequest is running, abort
console.log("2");
ajaxRequest.abort();
}
console.log("3");
ajaxRequest = $.ajax({
url: "/v1/Suggestions",
type: 'GET',
data: data,
headers: {},
success: obj.addrSuggestion.bind(obj),
error: function(error) {
console.log("FAILED getSuggestions" + JSON.stringify(error));
}
});
}});
so in success: obj.addrSuggestion.bind(obj), i want to pass the control details so that i can add condition to display it.