Tokens is an array and it is expecting a string. You could try d.tokens.join(' ')
, though not sure if you need a jQuery selector ($
) around d.
Bootstrap Typeahead Bloodhound tokenizer doesn't work with mulitple values
-
14-10-2022 - |
Question
Here's my javascript:
<script type="text/javascript">
$(document).ready(function () {
var people = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.tokens); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: [
{
fullName: '',
"],
},
{
fullName: 'Marijus Merkevicius',
tokens: ["Marijus Merkevicius", "marijusm"],
},
]
});
// initialize the bloodhound suggestion engine
people.initialize();
// instantiate the typeahead UI
$('#${id }').typeahead(null, {
displayKey: 'fullName',
source: people.ttAdapter(),
});
});
</script>
When I use return Bloodhound.tokenizers.whitespace(d.fullName);
autocomplete works perfectly however when I return d.tokens it doesn't at all. What am I doing wrong here ?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow