【发布时间】:2018-01-12 20:17:15
【问题描述】:
我希望能够根据从搜索中检索到的值更改模板。我想过像这样更改变量内容:
search.addWidget(
instantsearch.widgets.hits({
container: '#hits',
hitsPerPage: 12,
templates: {
empty: noResultsTemplate,
item: hitTemplate
},
transformData: function (hit) {
if (hit.myVariable == true) {
this.templates.item = otherTemplateVariable;
}
return hit;
}
})
);
但我得到一个错误:'Unable to get property 'templates' of undefined or null reference'
【问题讨论】:
标签: javascript jquery instantsearch.js