I have started to extend off of the chosen library by creating an on they fly tagging capability using knockout observables to hold the selected values, however i have run into a couple issues. Hoping someone can provide some help.
Observed issues:
Entering more than two tags removes any added items after the first entry and replaces it with last entered tag. Selecting options from the tag list works well, however entering a new tag forces the same behavior as previously mentioned.
Custom KO Binding:
ko.bindingHandlers.chosenTagging = {
init: function (element, valueAccessor, allBindings) {
$(element).chosen({ width: '100%', disable_no_results: true, enable_custom_content: true, placeholder_text_multiple: 'Enter Tag(s)' });
var valuesObservable = allBindings.get('selectedOptions');
var updateList = function () {
$(element).trigger('chosen:updated');
}
if (valuesObservable && typeof (valuesObservable.subscribe) == 'function') {
valuesObservable.subscribe(updateList);
}
},
update: function (element, valueAccessor, allBindings) {
$(element).trigger('chosen:updated');
}
};
JSFiddle :
http://jsfiddle.net/S3H2A/5/
Note: If you provide any additions to the chosen JS in fiddle, please state the line numbers where the changes were made.
Similar post found here: Add values to a chosen multiselect