【发布时间】:2015-07-21 01:58:36
【问题描述】:
我正在尝试执行远程提前输入功能。我的远程 JSON 应该如何构建?在下面的示例中,用户对每个项目都有一个单独的 JSON 文件。我必须为我的数据创建这数千个文件吗?
https://github.com/twitter/typeahead.js/tree/gh-pages/data/films/queries
示例如下:
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '../data/films/post_1960.json',
remote: {
url: '../data/films/queries/%QUERY.json',
wildcard: '%QUERY'
}
});
$('#remote .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures
});
【问题讨论】:
标签: typeahead.js