【问题标题】:typeahead - minLength to trigger the suggestion listtypeahead - minLength 触发建议列表
【发布时间】:2018-09-16 11:36:59
【问题描述】:

我将 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】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多