异步搜索提示的实现
/**
* 异步搜索
* @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>')
}
});
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。