工作事先鍵入的內容,如果我給一個靜態數組作爲源,但是當我試圖生成功能的陣列將不會填充其下拉列表。動態填充Twitter的引導事先鍵入的內容
$("#mix-artist").typeahead({
source: function(query, process) {
Mix.searchArtist(query);
},
minLength: 3,
});
爲源的功能:信號源功能的
searchArtist: function(query) {
$.get(API_MAIN_URL, {a: "search.artists", q: query},
function(data) {
artists = [];
query = query.toLowerCase();
if (data['aData']) {
for (var i = 0; i <= data['aData'].length; i++) {
if (data['aData'][i] && data['aData'][i]['sName'].toLowerCase().indexOf(query) == 0) {
artists.push(data['aData'][i]['sName']);
}
}
}
console.log(artists);
return artists;
});
}
輸出示例:
["Arcangel", "Arc Angels", "Arcade Fire", "Arctic Monkeys", "Archers of Loaf", "Architecture in Helsinki", "Archie Shepp", "Arcade", "Arch Enemy", "Arcadia", "Archie Eversole"]
我能做些什麼來獲得預輸入接受這個數組?
Twitter默認引導程序不接受函數源 –