ArrayEditable: replace self.$items

When shrinking the number of items, this allows the old elements to be
GCed sooner.
This commit is contained in:
Will Thompson 2016-05-04 11:17:56 +01:00 committed by j
parent 84b3c34130
commit adbf2dad81

View file

@ -142,23 +142,23 @@ Ox.ArrayEditable = function(options, self) {
}
that.empty();
if (self.options.items.length == 0) {
self.$items[0] = Ox.Editable({
self.$items = [Ox.Editable({
editable: false,
placeholder: self.options.placeholder,
type: self.options.type,
value: ''
})
.appendTo(that);
.appendTo(that)];
} else {
sortItems();
self.options.items.forEach(function(item, i) {
self.$items = self.options.items.map(function appendItem(item, i) {
if (i && self.options.type == 'input') {
$('<span>')
.addClass('OxSeparator')
.html(self.options.separator + ' ')
.appendTo(that);
}
self.$items[i] = Ox.Editable({
return Ox.Editable({
autocomplete: self.options.autocomplete,
autocompleteReplace: self.options.autocompleteReplace,
autocompleteReplaceCorrect: self.options.autocompleteReplaceCorrect,