2015-02-11 49 views
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类选择它们时。请参阅:

the problem with highlighting

而且在这种情况页面的HTML:

Groeitijd: 2 m 
<strong class="tt-highlight">a</strong> 
<strong class="tt-highlight">a</strong> 
nden. 

我不希望这highligting在模板Groeitijd: {{growingTime}}部分。我知道如何删除所有突出显示,但不知道模板中的某个特定部分。

有谁知道这是如何实现的?非常感谢。

回答

3

通过添加类没有突出来,我不想突出部分固定,如下所示:

<i class="no-highlighting">Groeitijd: {{growingTime}} maanden.</i><br/> 

和自凸显手段将围绕我们给这个元件的非匹配部分strong通过添加以下CSS来查看外观:

.no-highlighting strong { 
    font-weight:normal; 
} 
相关问题