typeahead.js: typeahead not showing all results if less than limit
I’m using typeahead with the following code:
$('#questionId .typeahead').typeahead(null, {
name: 'questions',
displayKey: 'question',
source: questionsList,
limit: 10,
templates: {
empty: '<p>message</p>',
suggestion: Handlebars.compile('<p>{{question}}</p>')
}
})
Where ‘questionsList’ is a Bloodhound instance. The suggestions seem to be working fine when the query’s number of matches is greater than ‘limit’ (10 in this case). But the problem is when the number of matches is <= limit. In that case, the number of suggestions displayed is max(limit - results, results). For instance, in my case when the query returns 10 matches, 0 results are displayed. When the query returns 8 matches, 2 results are displayed. When the query returns 3 matches, 3 results are displayed, and so on.
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 20
- Comments: 38
Commits related to this issue
- Fixed https://github.com/twitter/typeahead.js/issues/1232 — committed to dzhdmitry/typeahead.js by dzhdmitry 9 years ago
- Fix bug in auto-complete behaviour (see #193) Also see the original typeahead.js issue https://github.com/twitter/typeahead.js/issues/1232 — committed to dainst/ariadne-portal by scuy 7 years ago
- Wegen Bug in typeahed, limit Param hochgesetz Bug in typeahead https://github.com/twitter/typeahead.js/issues/1232 — committed to tbaddade/redaxo_watson by tbaddade 7 years ago
- use maintained fork of typeahead library I noticed while investigating a bug that the typeahead library is essentially abandoned: https://github.com/twitter/typeahead.js/issues/1232 One of the comm... — committed to dtao/boxofficehawk by dtao 7 years ago
- Add Employee Bugfix Fixes #131, weird typeahead bug, read about it here https://github.com/twitter/typeahead.js/issues/1232 — committed to colinpetruno/scheduleless by colinpetruno 7 years ago
- Patches typeahead.bundle.js to fix an error in results shown When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not adding t... — committed to juanluisrp/core-geonetwork by juanluisrp 6 years ago
- Patches typeahead.bundle.js to fix an error in results shown (#3332) When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows the first one, not... — committed to geonetwork/core-geonetwork by juanluisrp 6 years ago
- [BP] Patches typeahead.bundle.js to fix an error in results shown Backport of #3332. When the server returns less suggestions than what is configured as limit for the autocompleter, it only shows th... — committed to juanluisrp/core-geonetwork by juanluisrp 6 years ago
- [BP] Patches typeahead.bundle.js to fix an error in results shown (#3340) Backport of #3332. When the server returns less suggestions than what is configured as limit for the autocompleter, it on... — committed to geonetwork/core-geonetwork by juanluisrp 6 years ago
For anybody who wants a quick solution, just use
Infinityas the limit, and limit the results in your server response.@alestuber This repo is as dead as dead gets as far as I can tell. https://github.com/corejavascript/typeahead.js is the place to go.
limit: Infinitythanks for saving my day. peace!!!This repo seems abandoned… some kind souls continue maintaing it here: https://github.com/corejavascript/typeahead.js I’d say the useful thing to do is sending pull request there.
I’ve been using https://github.com/corejavascript/typeahead.js for a while now instead of this repo, and it works great. highly suggest migrating over there.
I have just spent hours trying to work out what the f***k was going on here and just come across this. I’m assuming this still isn’t fixed in 0.11.1 (the ver I’m using)? I had my limit set to 7. I’m returning no more than 7 results from the server. When the result set is e.g. 5, it’s only showing the first 2 etc.
Interestingly, in my case no result is displayed when the number of suggestions exactly equals the limit I set. I use the three parameters async source function.
@louy the
Infinitytrick worked for me as well. Thanks!There’s a simple way of solving this: put the limit to 20 and divide it by 2 in your server side.
I had the same problem and found the best option was to use a fork that already resolved this issue. https://github.com/per-nilsson/typeahead.js/tree/fix-async-render-dist