Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/editors/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Form.editors.Select = Form.editors.Base.extend({
* @return {String} HTML
*/
_arrayToHtml: function(array) {
var html = $();
var html = [];

//Generate HTML
_.each(array, function(option) {
Expand All @@ -221,18 +221,18 @@ Form.editors.Select = Form.editors.Base.extend({
var optgroup = $("<optgroup>")
.attr("label",option.group)
.html( this._getOptionsHtml(option.options) );
html = html.add(optgroup);
html.push(optgroup[0]);
} else {
var val = (option.val || option.val === 0) ? option.val : '';
html = html.add( $('<option>').val(val).text(option.label) );
html.push($('<option>').val(val).text(option.label)[0]);
}
}
else {
html = html.add( $('<option>').text(option) );
html.push($('<option>').text(option)[0]);
}
}, this);

return html;
return $().add(html);
}

});
23 changes: 23 additions & 0 deletions test/editors/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,29 @@
equal(newOptions.last().html(), 'Phil');
});


test('Rendering: Only adds options to the DOM with one function call ', function() {
var options = [],
length = 4000;

for(var i = 0;i < length;i++) {
options.push('option-' + i);
}

var editor = new Editor({
schema: {
options: options
}
});

var spy = sinon.spy($.fn, 'add');

editor.render();

equal(spy.callCount, 1);

});

test("setValue() - updates the input value", function() {
var editor = new Editor({
value: 'Pam',
Expand Down