Skip to content

Commit

Permalink
Set <option> label in updateOriginalInput (closes #512).
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreavis committed Jan 30, 2015
1 parent 2f6d295 commit f158a7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -1638,13 +1638,14 @@ $.extend(Selectize.prototype, {
* element to reflect the current state.
*/
updateOriginalInput: function(opts) {
var i, n, options, self = this;
var i, n, options, label, self = this;
opts = opts || {};

if (self.tagType === TAG_SELECT) {
options = [];
for (i = 0, n = self.items.length; i < n; i++) {
options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected"></option>');
label = self.options[self.items[i]][self.settings.labelField] || '';
options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
}
if (!options.length && !this.$input.attr('multiple')) {
options.push('<option value="" selected="selected"></option>');
Expand Down
1 change: 1 addition & 0 deletions test/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
click(test.selectize.$control, function() {
click($('[data-value="b"]', test.selectize.$dropdown), function() {
expect(test.selectize.$input.val()).to.be.equal('b');
expect(test.selectize.$input.text()).to.be.equal('B');
done();
});
});
Expand Down

0 comments on commit f158a7d

Please sign in to comment.