javascript - typeahead - minLength 触发建议列表
问题描述
我将 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,
});
推荐阅读
- sql - 显示在伦敦工作的销售人员的销售 ID 和销售日期
- java - Android Studio 4.0.1 GridLayout 使应用程序崩溃
- discord.js - 使用 Discord.js 音乐机器人获取视频的当前时间戳?
- python - 解决没有变量的 Python Pulp
- python - 熊猫在计算相应的最后一个工作日时更改月份
- apache-spark - 如何在 openshift 4.0 中获得对 pod 的 root 访问权限
- python - 安装 GANet
- angular - 如何在角度8中将文本框的值从一个组件获取到另一个组件,反之亦然
- sas - If-else 然后在 SAS 中执行
- ruby-on-rails - Rails Active Storage 和 AWS S3:如何通过 seed.rb 将图像附加到模型,然后将其存储在 S3 私有存储桶中?