【发布时间】:2014-07-13 22:38:35
【问题描述】:
我已经在 Hogan 2 中使用 Typeahead 0.9.3 有一段时间了,它的设置非常简单。
在 0.9.3 中我做了类似的事情:
$('input.search-query').typeahead([
{
name: "pages"
,local: localSuggestions
,template: '<div class="tt-suggest-page">{{value}}</div>'
,engine: Hogan
}
]);
根据Migration Guide to 0.10“现在需要预编译模板”,所以在 0.10.3 中我正在尝试:
$('input.search-query').typeahead(null, {
name: "pages"
,source: taSourceLocal.ttAdapter()
,templates: {
suggestion: Hogan.compile('<div class="tt-suggest-page">{{value}}</div>')
}
});
但它不起作用。我收到一个错误:Uncaught TypeError: object is not a function
如果有另一个可以工作的极简模板引擎,我也会考虑它,但它必须很小。我不想添加像 Handlebars 这样的大文件或像 Underscore 这样的整个库。
有什么想法吗?蒂亚!
【问题讨论】:
标签: javascript template-engine typeahead.js hogan.js twitter-typeahead