typeahead - minLength触发建议列表

问题描述 投票:0回答:1

我将minLength设置为3,以便在输入至少3个字符时触发建议列表。

但是当输入1个字符时,下拉列表会打开。如何使这个工作?

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

小提琴:https://jsfiddle.net/tomsx/bc6trhjk/

javascript typeahead.js bloodhound
1个回答
2
投票

根据这里的文件 - https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md#api,第一个参数是选项,它不能是空白。

将其更改为以下,它应该工作,

$('#remote .typeahead').typeahead({minLength: 3}, {
  name: 'best-pictures',
  display: 'value',
  source: bestPictures,
});
© www.soinside.com 2019 - 2024. All rights reserved.