简体   繁体   中英

Typeahead.js shows less results

When I go to the link http://127.0.0.1:8000/hashtag.json?q=g to check the JSON, I get a list like this: [{"q": "#django"}, {"q": "#hashtag"}, {"q": "#hashtags"}, {"q": "#google"}]

and when I type in the input the letter g, I get only "django" in a dropdown shown as a suggestion

when i type in: go I get 2 results in my JSON list and also 2 suggestions in the dropdown: django and google

What may be the problem?

I dont think there might be an issue in my code. But I still decided to post it here.

var hashTags = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('q'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '/hashtag.json?q=%QUERY',
remote: {
url: '/hashtag.json?q=%QUERY',
wildcard: '%QUERY'
}
});

$('.search-tag-query').typeahead({
    hint:true,
    highlight: true,
    autoselect:true,
    minLength:1,
    limit: 10,
},
    {
    name: 'hashTags',
    displayKey: 'q',
    source: hashTags.ttAdapter(),
});

I got it done by going to this link.

https://github.com/getyourguide/typeahead.js/commit/6fc8051fec273d0fa0c8a9340446aad07923c34c#diff-87840d06427d49e9679178b8d1564171

and using this code from typeahead.bundle.min.js I copied it and pasted it instead of the code in my typeahed.bundle.js

This is some issue in versions off typeahead I guess, that was solved and not posted in the official bundle somehow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM