Search code examples
typeahead.js

Limit number suggestions display in typeahead.js


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)


Solution

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