fix a bug regarding the value of empty array inputs

This commit is contained in:
rlx 2012-01-13 15:01:16 +05:30
parent 8b589283f6
commit 923ed92bd7

View file

@ -17,10 +17,6 @@ Ox.ArrayInput = function(options, self) {
}) })
.options(options || {}); .options(options || {});
if (self.options.value.length == 0) {
self.options.value = [''];
}
if (self.options.label) { if (self.options.label) {
self.$label = Ox.Label({ self.$label = Ox.Label({
title: self.options.label, title: self.options.label,
@ -34,7 +30,9 @@ Ox.ArrayInput = function(options, self) {
self.$removeButton = []; self.$removeButton = [];
self.$addButton = []; self.$addButton = [];
self.options.value.forEach(function(value, i) { (
self.options.value.length ? self.options.value : ['']
).forEach(function(value, i) {
addInput(i, value); addInput(i, value);
}); });
@ -126,13 +124,12 @@ Ox.ArrayInput = function(options, self) {
} }
function setValue() { function setValue() {
if (self.options.value.length == 0) {
self.options.value = [''];
}
while (self.$input.length) { while (self.$input.length) {
removeInput(0); removeInput(0);
} }
self.options.value.forEach(function(value, i) { (
self.options.value.length ? self.options.value : ['']
).forEach(function(value, i) {
addInput(i, value); addInput(i, value);
}); });
} }