2
我使用的是typeahead with bloodhound with a custom template和Bootstrap css file。我的模板是如上述这样看的第一个链接:如何忽略Typeahead.js中突出显示的部分模板?
$(function() {
cropsSuggestionEngine.initialize();
$('#select-crop .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'Gewassen',
displayKey: 'name',
source: cropsSuggestionEngine.ttAdapter(),
templates: {
empty: ['<div class="empty-message">','Niets gevonden...','</div>'].join('\n'),
suggestion: Handlebars.compile('<p><strong>{{name}}</strong> in {{category}}<br/>'
+ 'Ras: {{race}}.<br/>'
+ '<i>Groeitijd: {{growingTime}} maanden.</i><br/>'
+ '<input type="hidden" name="selected-crop-id" value={{id}}></p>')
}
});
});
什么不幸发生的情况是一致的模板,所有的元素,会亮显,因为他们得到了“TT-亮点” CSS类选择它们时。请参阅:
而且在这种情况页面的HTML:
Groeitijd: 2 m
<strong class="tt-highlight">a</strong>
<strong class="tt-highlight">a</strong>
nden.
我不希望这highligting在模板Groeitijd: {{growingTime}}
部分。我知道如何删除所有突出显示,但不知道模板中的某个特定部分。
有谁知道这是如何实现的?非常感谢。