トークンが機能しません。'east'、'home'、または 'trap' と入力すると、'Inkoopverenigen' と表示されるはずですが、何が問題なのですか?
json:
[
{
"value": "Inkoopverenigingen",
"tokens": [
"inkoopverenigingen",
"inwoopverenigingen",
"east",
"home",
"trap"
]
},
{
"value": "Aannemers - Afbraakwerken",
"tokens": [
"West",
"Side",
"Story"
]
},
{
"value": "Affichageondernemingen",
"tokens": [
"West",
"Side",
"Story"
]
},
{
"value": "Aanwervingsbureaus",
"tokens": [
"West",
"Side",
"Story"
]
}
]
JavaScript:
var engine = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 15,
prefetch: 'data/typeahead/what.json',
remote: 'data/typeahead/queries/%QUERY.json'
});
engine.initialize();
engine.clearPrefetchCache();
var template_source = $("#entry-template-what").html();
$('.test .typeahead-what').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'what',
displayKey: 'value',
// `ttAdapter` wraps the suggestion engine in an adapter that
// is compatible with the typeahead jQuery plugin
source: engine.ttAdapter(),
templates: {
empty: no_results,
suggestion: Handlebars.compile(template_source)
}
}
);
html:
<div class="test">
<input type="text" class="typeahead-what form-control" id="section" name="section">
</div>
html テンプレート:
<script id="entry-template-what" type="text/x-handlebars-template">
<div>
<strong>{{value}}</strong>
<div class="controls pull-right">
<span class="glyphicon glyphicon-plus"></span>
<span class="glyphicon glyphicon-minus"></span>
</div>
</div>