Typeahead.js 0.10支持页眉和页脚以及搜索结果的模板.我希望能够获得每个类别的实际结果/建议数(即忽略限制值)并在类别名称标题中显示.
例如 -
结果:
我的模板目前看起来像这样:
{
name: 'Applications',
displayKey: 'value',
source: app.ttAdapter(),
extraVars:Handlebars.registerHelper("numResults",function(){
return ( "HowToGetTheseResults??" );
}),
templates: {
header:Handlebars.compile([
'<h3 class="applications"> Applications ({{numResults}}) results </h3>'
].join('')),
suggestion: Handlebars.compile([
'<p><b>{{value}}</b> </p>'
].join(''))
}
Run Code Online (Sandbox Code Playgroud)
是否有一种简单的方法可以提前输入结果/建议的数量?我确定typeahead对象(或者是bloodhound对象?)必须在某个地方存储这些数据.