Open CodeBradley opened 6 years ago
when you were using remote mode , did you filter the data in your backend server code based on URL query parameter before you return them back to client? The following code snippet show URL with query parameter send to server for filtering the return data:
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// prefetch: 'assets/data/post_1960.json',
remote: {
url: 'assets/data/post_1960.json?q=%QUERY%',
wildcard: '%QUERY%'
}
});
$('#remote').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures
});
This API does not have a way to query/filter the data, it only returns everything when visiting a particular endpoint. What I don't understand is if there is already code to filter the data when sourcing it locally, shouldn't the same code work on data obtained remotely? (I haven't had a chance to skim the source just yet, but that's what I assumed.)
same issue
I also remove prefetch
and works
I've written an in-depth question on StackOverflow which will allow you to see "CodePen" style snippets, I'm not sure how to do this on GitHub. Basically though, when I use remote in BloodHound my results aren't being filtered correctly but when I switch remote to local and place the data in a local variable the code works fine. I have no clue what's different other than where the data is obtained.
https://stackoverflow.com/questions/49240475/twitter-typeahead-js-bloodhound-keeps-showing-same-results-regardless-of-text