corejavascript/typeahead.js

Can't seem to get tokenizer working on specific key

Opened this issue · 0 comments

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": "<div class=\"wpib wpib-icon wpib-icon-dashboard wpib-icons-sprite\"></div>"
	}
]

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

What am I doing wrong here?