I have an issue with Bootstrap tokenfield when I'm using an Object with more than one field. For example, I get no issues when I use a json object is defined as:
local: [ { value: 'red' }, { value: 'orange' }} ]
The initializer for this is:
$('#tokenfield-input').tokenfield({
typeahead: [null, { source: engine.ttAdapter(),
displayKey: 'value',
displayValue: 'value'
}]
});
This works correctly.
However, if I add another field, it throws an error Cannot read property 'toString' of undefined
when the token is selected. The json is defined as:
local: [ { id: 1, value: 'red' }, { id: 2, value: 'orange' }} ]
The initializer for this is:
$('#tokenfield-input').tokenfield({
typeahead: [null, { source: engine.ttAdapter(),
displayKey: 'value',
displayValue: 'id'
}]
});
The fiddle here contains a live example. What would be the correct way to do this?