我将minLength设置为3,以便在输入至少3个字符时触发建议列表。
但是当输入1个字符时,下拉列表会打开。如何使这个工作?
$('#remote .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures,
minLength: 3
});
根据这里的文件 - 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,
});