Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple value keys #157

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function resolve_datasets($e, source) {
var templateName = $e.data('template'); // specifies name of custom template
var templates = $e.data('templates'); // specifies custom templates
var valueKey = $e.data('value-key') || 'value';
var displayKey = $e.data('display-key') || valueKey;
var minLength = get_min_length($e);

if (!source) {
Expand All @@ -161,7 +162,7 @@ function resolve_datasets($e, source) {
var dataset = {
name: name,
valueKey: valueKey,
displayKey: valueKey,
displayKey: displayKey,
minLength: minLength,
};

Expand Down Expand Up @@ -430,6 +431,16 @@ function make_bloodhound(dataset) {
var engine;

if (need_bloodhound) {
// Here we parse the keys?
// if (valueKey.indexOf(" ") !== -1) {
// dataset.valueKey = dataset.valueKey.split(" ");
// };
// Supports multiple valuekeys, deliniated by commas
if (dataset.valueKey.indexOf(",") !== -1) {
dataset.valueKey = dataset.valueKey.replace(/\s+/g, '').split(",");
};


var options = $.extend({}, dataset, {
// TODO support custom tokenizers
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(dataset.valueKey),
Expand Down