Skip to content

Commit f158a7d

Browse files
committed
Set <option> label in updateOriginalInput (closes #512).
1 parent 2f6d295 commit f158a7d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/selectize.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,13 +1638,14 @@ $.extend(Selectize.prototype, {
16381638
* element to reflect the current state.
16391639
*/
16401640
updateOriginalInput: function(opts) {
1641-
var i, n, options, self = this;
1641+
var i, n, options, label, self = this;
16421642
opts = opts || {};
16431643

16441644
if (self.tagType === TAG_SELECT) {
16451645
options = [];
16461646
for (i = 0, n = self.items.length; i < n; i++) {
1647-
options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected"></option>');
1647+
label = self.options[self.items[i]][self.settings.labelField] || '';
1648+
options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
16481649
}
16491650
if (!options.length && !this.$input.attr('multiple')) {
16501651
options.push('<option value="" selected="selected"></option>');

test/interaction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
click(test.selectize.$control, function() {
5454
click($('[data-value="b"]', test.selectize.$dropdown), function() {
5555
expect(test.selectize.$input.val()).to.be.equal('b');
56+
expect(test.selectize.$input.text()).to.be.equal('B');
5657
done();
5758
});
5859
});

0 commit comments

Comments
 (0)