smolo
smolo

Reputation: 879

typeahead - minLength to trigger the suggestion list

I set minLength to 3 to trigger the suggestion list when at least 3 characters have been typed in.

But the dropdown opens when 1 character is typed in. How to make this work?

$('#remote .typeahead').typeahead(null, {
  name: 'best-pictures',
  display: 'value',
  source: bestPictures,
  minLength: 3
});

Fiddle: https://jsfiddle.net/tomsx/bc6trhjk/

Upvotes: 2

Views: 3058

Answers (1)

Akshay
Akshay

Reputation: 3866

According to the document here - https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md#api, the first argument is options, it cannot be blank.

Change it to following and it should work,

$('#remote .typeahead').typeahead({minLength: 3}, {
  name: 'best-pictures',
  display: 'value',
  source: bestPictures,
});

Upvotes: 4

Related Questions