【发布时间】:2014-06-26 21:29:54
【问题描述】:
是否有可能在所有建议的末尾添加自定义行?我想添加一个“显示更多建议”,它是指向另一个页面的链接。
$(function(){
var countries = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url : '/json/temp/countries.json',
filter: function(list) {
return $.map(list, function(country) { return { name: country }; });
}
},
});
countries.initialize();
$('.component-search-button .ui-input input').typeahead(null,
{
highlight: true,
name: 'countries',
displayKey: 'name',
source: countries.ttAdapter(),
templates: {
empty: [
'<div class="empty-message">',
'<i>Unfortunatelly we coud not find items that match the current query. Please try again.</i>',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<p><strong>{{name}}</strong></p>')
}
}
);
});
它遵循 Git 上的基本示例。我看到错误消息在“模板”中的“空”处触发,它有一个选项可以在列表完成或类似的情况下触发。
非常感谢您的帮助。
【问题讨论】:
-
请添加您自己的答案作为答案并接受。
-
是的,它有帮助,谢谢 :) 我要使用'footer' ????
-
我建议你编辑你的帖子,从问题中删除你的答案,然后回答你自己的问题,这样它就不会被标记为未回答。
标签: handlebars.js typeahead.js typeahead