异步搜刮提醒的完成
/**
* 异步搜刮
* @type {Bloodhound}
*/
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('data'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: GUI.data.API.searchUser,
rateLimitWait: 700,
prepare: function(query, settings) {
console.log(query);
settings.type = "POST";
settings.contentType = "application/x-www-form-urlencoded; charset=UTF-8";
settings.data = {
keyName: query
};
return settings;
},
transform: function(response){
console.log(response);
return response.data
}
}
});
$('#the-basics .typeahead').typeahead(null, {
name: 'best-pictures',
limit: '11',
display: 'data',
source: bestPictures,
templates: {
empty: [
'<div class="empty-message">',
'没有查询到相干的纪录',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<div class="result-item">{{name}} <span class="small">{{deptName}}</span></div>')
}
});