I have been using typeahead and bloodhound for a project and I find it really unintuitive as well as frustrating. Something that should take a second to do ends up in an hour of research.
Anyway i'm trying to alert the number of results into my bloodhound.
Here's my code so far
var pisList = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: "../Helper/LookUpPIs?list=" + $list,
cache: false
}
});
alert(pisList.length);
//Typeahead on project numbers
$('.pis').typeahead({
hint: true,
higlight: true,
minLength: 1
},
{
name: 'pis',
source: pisList
});
//Display project details distribution panel
$('input.pis').on('typeahead:selected', function (event, selection) {
var result = selection.match(/\((.*)\)/);
getPiInformation(result[1]);
});
return false;
}
Right now my alert return me undefined. I tried multiple variants but none of them were successful.
Let me know if you have a hint and thanks in advance.