Limit number suggestions display in typeahead.js
Asked Answered
S

3

7

As the title, I want to ask: "Is it possible to limit the suggestions displayed in typeahead?"

For example, I have 3 datasets, each dataset has 10000 results (from the query). And a subject started with character t is about 3000 results or may be more.

What will happened if I type t in the input ? 3000 result display or ... ?

Or is there any way to force user type specific characters then display suggestions ? (Like I must type tem, single character like t will not be accpeted)

Soembawa answered 28/7, 2013 at 20:13 Comment(0)
G
13

You should use a combination of limit and minLength. limit is the max number of suggestions that will be displayed for a given query (defaults to 5) and minLength is the minimum number of characters a query needs before suggestions start to get rendered (defaults to 0).

Griff answered 29/7, 2013 at 17:24 Comment(3)
Actually default value for minLength is 1(at least now) github.com/twitter/typeahead.js/blob/master/src/typeahead/…Willaims
this is not valid for the latest. if you are using bloodhound, limit is an option on bloodhound, while minLength is an option on typeaheadRagouzis
I needed to add the 'items' option instead of 'limit'. I have bootstrap3-typeahead.js v3.1.0Ful
T
8

The default limit is 5, you can set the "limit" option to what you want.

Read the doc ;-)

Trinetta answered 28/7, 2013 at 20:27 Comment(0)
C
0

For limiting suggestions Use "items: x", where x will be the number of suggestion to be displayed after typing some character. e.g, if items: 5, then 5 suggestions will be shown at max for whatever you typed.

Crucifer answered 11/6, 2019 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.