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

Bloodhound discards suggestions fetched from remote #1768

Closed JakupGuven closed 4 years ago

JakupGuven commented 4 years ago

I have an issue with a specific search string where Bloodhound receives four elements from remote that I'd like to have displayed as suggestions.

Instead only one suggestion is displayed.

I can tell that the elements are actually received by Bloodhound by making a custom transform simply displaying the response. However when I don't define a custom transform some where along the way the would-be suggestions dissappear.

UPDATE: After further debugging I've discovered that the elements are still present after function processRemote(remote) is called.

source: new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('Title'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: {
                            url: '/api/suggest/' + p + '/%QUERY',
                            wildcard: '%QUERY',
                            //transform: function (response) {
                            //    console.log(response)
                            //}
                        },

                    }),
                    templates: {
                        header: '<h3 class="league-name">' + data[p].charAt(0).toUpperCase() + data[p].slice(1) + '</h3>',
                        suggestion: function (d) {
                            return "<a href=" + d.Url + "><span>" + d.Title + "</span></a>"
                        }
                    }
                };

Did anyone experience similar issues? How can I solve this?

JakupGuven commented 4 years ago

results These are the elements. Only the first one ends up being displayed.

JakupGuven commented 4 years ago

It was the same issue as this PR from 2016 addresses https://github.com/twitter/typeahead.js/pull/1566