fix setting value on array lists

This commit is contained in:
j 2014-02-13 09:28:43 +00:00
parent bb0b8c247c
commit 7b5d24461d

View file

@ -1819,7 +1819,8 @@ Ox.List = function(options, self) {
id = args.shift(), id = args.shift(),
pos = Ox.isNumber(id) ? id : getPositionById(id), pos = Ox.isNumber(id) ? id : getPositionById(id),
$item = self.$items[pos], $item = self.$items[pos],
data = $item ? $item.options('data') : {}; data = $item ? $item.options('data') : {},
updateItems = false;
if (arguments.length == 1) { if (arguments.length == 1) {
return data; return data;
} else if (arguments.length == 2 && Ox.isString(arguments[1])) { } else if (arguments.length == 2 && Ox.isString(arguments[1])) {
@ -1834,10 +1835,22 @@ Ox.List = function(options, self) {
} }
if (!self.isAsync) { if (!self.isAsync) {
self.options.items[pos][key] = value; self.options.items[pos][key] = value;
} else if(self.items) {
self.items[Ox.getIndexById(self.items, id)][key] = value;
updateItems = true;
} }
data[key] = value; data[key] = value;
}); });
$item.options({data: data}); $item.options({data: data});
if (updateItems) {
self.options.items = Ox.api(self.items, {
cache: true,
map: self.options.map,
sort: self.options.sort,
sums: self.options.sums,
unique: self.options.unique
});
}
return that; return that;
} }
}; };