Skip to content

Commit

Permalink
Avoid issue with splitting on commas
Browse files Browse the repository at this point in the history
Original implementation would split on commas, meaning that you couldn't enter a comma. Worked around this limitation by using a select element instead of an input element and ensure that the value we mine from that element comes from selectize as ab array
  • Loading branch information
Phil Ostler committed Sep 14, 2015
1 parent 475405f commit b2cff33
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/editors/array/selectize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
JSONEditor.defaults.editors.arraySelectize = JSONEditor.AbstractEditor.extend({
build: function() {

var self = this;

this.title = this.theme.getFormInputLabel(this.getTitle());

this.title_controls = this.theme.getHeaderButtonHolder();
Expand All @@ -13,21 +10,19 @@ JSONEditor.defaults.editors.arraySelectize = JSONEditor.AbstractEditor.extend({
this.description = this.theme.getDescription(this.schema.description);
}

this.input = document.createElement('input');
this.input.setAttribute('type', 'text');
this.input = document.createElement('select');
this.input.setAttribute('multiple', 'multiple');

var group = this.theme.getFormControl(this.title, this.input, this.description);

this.container.appendChild(group);
this.container.appendChild(this.error_holder);

window.jQuery(this.input).selectize({
delimiter: ',',
delimiter: false,
createOnBlur: true,
create: true
});


},
postBuild: function() {
var self = this;
Expand Down Expand Up @@ -62,7 +57,7 @@ JSONEditor.defaults.editors.arraySelectize = JSONEditor.AbstractEditor.extend({
this.refreshValue(initial);
},
refreshValue: function(force) {
this.value = this.input.value.split(',');
this.value = this.input.selectize.getValue();
},
showValidationErrors: function(errors) {
var self = this;
Expand Down

0 comments on commit b2cff33

Please sign in to comment.