Reputation: 309
In the following JSFiddle Code, The list of location is parsed from the jSON object and shown. I would like to add a search and a type ahead functionality to it. The following code is not working.
var sourceArr = [];
for (x in data.sessions) {
sourceArr.push(data.sessions[x].ID);
}
$(".search").typeahead({
source: sourceArr
});
$(".search").keyup(function () {
var userInput = $(this).val();
$(".findsession-list li").map(function (index, value) {
$(value).toggle($(value).text().toLowerCase().indexOf(userInput) >= 0);
});
});
Upvotes: 1
Views: 714
Reputation: 8623
Not sure what do you expect from typeahead but you should use local
instead of source
:
$(".search").typeahead({
local: sourceArr
});
Fiddle: http://jsfiddle.net/hieuh25/WsnDP/22/
Upvotes: 2