Choices
Choices copied to clipboard
How do u modify an existing Value without Being Forced to Delete then Add The Modification Back?
So here is how i create my choices...
keywordChoices = new Choices(document.getElementById('keywords'), {
delimiter: ',',
editItems: true,
maxItemCount: -1,
duplicateItemsAllowed: false,
removeItemButton: true,
shouldSortItems: true,
sorter: function(a, b) {
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
},
allowHTML: true,
placeholderValue: 'Type a keyword or phrase.',
items: keywordsArray
});
But once i set items how do i modify existing ones?
Currently i am forced to do the following where i delete the key then i read it with a modified value/label:
keywordChoices.removeActiveItemsByValue(key);
keywordChoices.setValue([{value: key, label: key}]);
Seems horribly inefficient. Surely, there has to be a way to udpate an existing value more easily.