我正在使用 twitter 的typeahead.js。当我使用远程获取 json 时,它会显示前 5 个 json 字符串,而与我在文本框中输入的字符无关。
这是配置
$("#search").typeahead({
name: 'categories',
cache: false,
remote: 'http://localhost:3000/api/v1/charts/sales/categories?chart_token=atoken',
valueKey: 'name'
});
上面的 url 返回以下 json
[{"id":"22","name":"PC"},{"id":"185","name":"XBOX 360"},{"id":"31","name":"Keräilykortti"},{"id":"34","name":"Manga + Kirjat"},{"id":"3","name":"DVD-elokuvat"},{"id":"202","name":"Wii"},{"id":"552","name":"Wii U"},{"id":"431","name":"Laitteet"},{"id":"535","name":"Nintendo 3DS"},{"id":"167","name":"Nintendo DS"},{"id":"206","name":"PlayStation 3"},{"id":"172","name":"PSP"},{"id":"26","name":"PlayStation 2"},{"id":"532","name":"PS Vita"},{"id":"25","name":"Xbox"},{"id":"241","name":"BLU-RAY-elokuvat"},{"id":"178","name":"Erikoistuotteet"},{"id":"30","name":"Games Workshop"},{"id":"328","name":"Flames of War"},{"id":"513","name":"Muut miniatyyripelit"},{"id":"32","name":"Roolipelit"},{"id":"33","name":"Lautapelit"}]
如果我使用local
上面的 json 而不是remote
它可以完美地工作。
知道我在这里缺少什么吗?