1
0
Fork 0
forked from 0x2620/oxjs

fix bugs in treelist where the icon would not update, items would not expand, and expanding items would be slow

This commit is contained in:
rlx 2011-10-01 13:06:50 +00:00
commit b3e7945a96
3 changed files with 67 additions and 58 deletions

View file

@ -692,8 +692,8 @@ Ox.List = function(options, self) {
});
self.selected.length && scrollToPosition(self.selected[0]);
// that.triggerEvent('init', {items: self.options.items.length});
// fixme: do async lists need to trigger init?
// will this only be reached in async lists?
// fixme: do sync lists need to trigger init?
// will this only be reached in sync lists?
}
function loadPage(page, callback) {
@ -1397,8 +1397,7 @@ Ox.List = function(options, self) {
@*/
that.addItems = function(pos, items) {
var $items = [],
length = items.length
//first = self.$items.length == 0;
length = items.length;
self.selected.forEach(function(v, i) {
if (v >= pos) {
self.selected[i] += length;
@ -1422,11 +1421,9 @@ Ox.List = function(options, self) {
$item.insertAfter($items[i - 1]);
}
});
self.options.items.splice.apply(self.options.items, Ox.merge([pos, 0], items));
self.$items.splice.apply(self.$items, Ox.merge([pos, 0], $items));
//if(first)
loadItems();
//loadItems();
updatePositions();
}
@ -1548,12 +1545,13 @@ Ox.List = function(options, self) {
length <n> number of items to remove
@*/
that.removeItems = function(pos, length) {
if(!length) { //pos is list of ids
Ox.print('removeItems', pos, length)
if (Ox.isUndefined(length)) { // pos is list of ids
pos.forEach(function(id) {
var p = getPositionById(id);
that.removeItems(p, 1);
});
} else { //remove items from pos to pos+length
} else { // remove items from pos to pos+length
Ox.range(pos, pos + length).forEach(function(i) {
self.selected.indexOf(i) > -1 && deselect(i);
self.$items[i].removeElement();
@ -1667,6 +1665,8 @@ Ox.List = function(options, self) {
return id_ == data[key] ? value : id_
});
}
self.options.items[pos][key] = value;
if (pos == 0) Ox.print(self.options.items[pos])
data[key] = value;
$item.options({data: data});
return that;