twitter / typeahead.js

typeahead.js is a fast and fully-featured autocomplete library
http://twitter.github.io/typeahead.js/
MIT License
16.52k stars 3.21k forks source link

AutoComplete Shows Same Results When Using BloodHound Remote, Regardless of Characters Entered Into Text Input #1713

Open CodeBradley opened 6 years ago

CodeBradley commented 6 years ago

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

JavaTMP commented 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
});
CodeBradley commented 6 years ago

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.)

prasetyo-jeanu commented 5 years ago

same issue I also remove prefetch and works