javascript 需要 Bootstrap Typeahead 本地、预取或远程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16089875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 03:14:04  来源:igfitidea点击:

Bootstrap Typeahead local, prefetch, or remote is required

javascriptjquerytypeahead.jsbootstrap-typeaheadtwitter-typeahead

提问by daniel

I try to get this exampleof twitters typeahead to run but i am getting the error in chromes console:

我尝试让这个twitters typeahead示例运行,但我在 chromes 控制台中收到错误:

Uncaught Error: one of local, prefetch, or remote is required jquery-1.9.1.js:507

未捕获的错误:需要本地、预取或远程之一 jquery-1.9.1.js:507

I am using typeayhead 0.9.1 (Nuget-Package). Is this a version problem? All examples set the source and not local/prefetch/remote in the request.

我正在使用 typeayhead 0.9.1 (Nuget-Package)。这是版本问题吗?所有示例都在请求中设置源而不是本地/预取/远程。

EDIT: Turned out that Twitter Bootstrap Typeahead and Twitter Typeahead are two different libraries.

编辑:原来 Twitter Bootstrap Typeahead 和 Twitter Typeahead 是两个不同的库。

采纳答案by Simon Boudrias

This only means you need to give a list in which Typeahead will search for completion value.

这仅意味着您需要提供一个列表,Typeahead 将在其中搜索完成值。

You must really pass at least one data source (prefetchor remote) or a data set (local).

您必须真正传递至少一个数据源(prefetchremote)或数据集(local)。

https://github.com/twitter/typeahead.js#jquerytypeaheaddatasets

https://github.com/twitter/typeahead.js#jquerytypeaheaddatasets



Also, should be noted that Twitter typeaheadand Twitter Bootstrap typeaheadain't the same plugin. They have different API. The article you read speak about Twitter Bootstrap typeahead: http://twitter.github.io/bootstrap/javascript.html#typeaheadbut you used it as Twitter typeahead!

另外,应该注意的是Twitter typeaheadTwitter Bootstrap typeahead不是同一个插件。他们有不同的API。您阅读的文章谈到了 Twitter Bootstrap 提前输入:http: //twitter.github.io/bootstrap/javascript.html#typeahead但您将其用作 Twitter 提前输入!