corejavascript / corejavascript/typeahead.js

Can't seem to get tokenizer working on specific key

Open
#205 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
968
Forks
231
PR merge metrics
No merged PRs in 30d

Description

I have troubles getting the Bloodhound tokenizer to work currently. I only want it to match on the `value` key in the result set, but it seems to only want to match on `name` key.

This is my code:

var menuResults = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: source + '&return_menu_items',
cache: true
},
remote: {
url: source + '&return_custom_events&q=%QUERY',
wildcard: '%QUERY'
}
});

This is my result set from prefetch:

[
{
"name": "Dashboard",
"value": "dasssh",
"link": "https://website.test/wp-admin/index.php",
"icon": "

"
}
]

Still, when I write "dass" the result does not show up. If I write "Dash" it shows up.

What am I doing wrong here?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.