当返回的结果是一个数组时,typeahead.js 效果很好:
var simpleCountriesList = [
"Andorra",
"United Arab Emirates",
"Afghanistan",
"Antigua and Barbuda"
];
在我的例子中,有一个对象数组,但它被包裹在一个像这样的对象中:
var countryObjectsWrappedInResults = {
"results":[
{
"name":"Andorra"
},
{
"name":"United Arab Emirates"
},
{
"name":"Afghanistan"
},
{
"name":"Antigua and Barbuda"
}
]
};
或者
{
"maintainers":[
{
"name":"Jake Harding",
"url":"https://twitter.com/JakeHarding"
},
{
"name":"Tim Trueman",
"url":"https://twitter.com/timtrueman"
},
{
"name":"Veljko Skarich",
"url":"https://twitter.com/vskarich"
}
]
}
我创建了一个小的 jsbin 来说明本地和远程的问题:http: //jsbin.com/OseWeKA/5/edit
我正在从 bootstrap typeahead 迁移,在那里我可以使用 updater 将数组从结果中弹出。twitter.js 的等价物是什么?