Skip to content

Commit e0b927c

Browse files
AlfonsoUcedarisadams
authored andcommitted
Allow JSON as value select options
1 parent 05fda66 commit e0b927c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/selectize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ $.extend(Selectize.prototype, {
19281928
old = existing.filter(function(value) {
19291929
return values.indexOf(value) < 0;
19301930
}).map(function(value) {
1931-
return 'option[value="' + value + '"]';
1931+
return 'option[value="' + escape_html(value) + '"]';
19321932
});
19331933

19341934
if (existing.length - old.length + fresh.length === 0 && !self.$input.attr('multiple')) {

test/api.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@
530530
{value: 0},
531531
{value: 1},
532532
{value: 2},
533-
{value: 3},
533+
{value: JSON.stringify({"type":"place"})},
534534
],
535535
items: ['1','2','3']
536536
});
@@ -549,7 +549,7 @@
549549
// {value: 0},
550550
// {value: 1},
551551
// {value: 2},
552-
// {value: 3},
552+
// {value: JSON.stringify({"type":"place"})},
553553
// ],
554554
// items: ['1','2','3']
555555
// });
@@ -561,7 +561,7 @@
561561
window.setTimeout(function() {
562562
expect(test.selectize.$dropdown_content.find('[data-value=1]').length).to.be.equal(1);
563563
expect(test.selectize.$dropdown_content.find('[data-value=2]').length).to.be.equal(1);
564-
expect(test.selectize.$dropdown_content.find('[data-value=3]').length).to.be.equal(1);
564+
expect(test.selectize.$dropdown_content.find('[data-value*="type"]').length).to.be.equal(1);
565565
done();
566566
}, 0);
567567
}, 0);
@@ -574,7 +574,7 @@
574574
test.selectize.clear();
575575
expect(test.selectize.$control.find('[data-value=1]').length).to.be.equal(0);
576576
expect(test.selectize.$control.find('[data-value=2]').length).to.be.equal(0);
577-
expect(test.selectize.$control.find('[data-value=3]').length).to.be.equal(0);
577+
expect(test.selectize.$control.find('[data-value*="type"]').length).to.be.equal(0);
578578
});
579579
it('should not fire "change" if silent is truthy', function(done) {
580580
var watcher = function(e) { throw new Error('Change fired'); };

0 commit comments

Comments
 (0)