【发布时间】:2015-02-03 08:43:46
【问题描述】:
我已经将 Twitter Typeahead.js 集成到 Rails 应用程序中已有一段时间了,并且运行良好。
在一系列 gem 更新和一些依赖项移动到 Bower 之后,我现在在控制台中看到一个错误,并且没有正确调用 Typeahead.js。
Uncaught TypeError: Cannot read property 'whitespace' of undefined
在
queryTokenizer: Bloodhound.tokenizers.whitespace
这是什么意思,我该如何调试?
我的完整代码:
jQuery ->
if $('.country-typeahead').length
countries = new Bloodhound(
prefetch:
url: "../api/countries.json"
datumTokenizer: (datum) ->
Bloodhound.tokenizers.whitespace datum.name
queryTokenizer: Bloodhound.tokenizers.whitespace
)
countries.initialize()
$('.country-typeahead').typeahead null,
name: "countries"
displayKey: "name"
source: countries.ttAdapter()
json 看起来像这样
[{"id":1,"name":"Aruba"},{"id":2,"name":"Afghanistan":""},{.....etc}]
【问题讨论】:
标签: ruby-on-rails typeahead.js bloodhound