我正在使用带有自定义模板和 Bootstrap css文件的 Bloodhound 预输入。我的模板与上面的第一个链接一样,如下所示:
$(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-highlight”css 类。看:
在页面的 HTML 中会发生这种情况:
Groeitijd: 2 m
<strong class="tt-highlight">a</strong>
<strong class="tt-highlight">a</strong>
nden.
我不希望Groeitijd: {{growingTime}}
对模板中的部分进行这种突出显示。我知道如何删除所有突出显示,但不适用于模板中的特定部分。
有谁知道如何做到这一点?非常感谢。