diff --git a/source/Ox.UI/js/List/List.js b/source/Ox.UI/js/List/List.js index a5b1ca16..32c8ccd5 100644 --- a/source/Ox.UI/js/List/List.js +++ b/source/Ox.UI/js/List/List.js @@ -103,7 +103,7 @@ Ox.List = function(options, self) { sort: self.options.sort, sums: self.options.sums, unique: self.options.unique - }); + }); /* self.listLength = self.options.items.length; updateSelected(); @@ -833,45 +833,45 @@ Ox.List = function(options, self) { var keys = Ox.unique(self.options.keys.concat(self.options.unique)), offset = page * self.pageLength, range = [offset, offset + getPageLength(page)]; - if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already - self.$pages[page] = constructEmptyPage(page); - page == 0 && fillFirstPage(); - self.$pages[page].appendTo(that.$content); - self.requests.push(self.options.items({ - keys: keys, - query: self.options.query, - range: range, - sort: self.options.sort - }, function(result) { - var $emptyPage = self.$pages[page]; - self.$pages[page] = $('
').addClass('OxPage').css(getPageCSS(page)); - result.data.items.forEach(function(v, i) { - var pos = offset + i; - self.$items[pos] = Ox.ListItem({ - construct: self.options.construct, - data: v, - //format: self.options.format, - position: pos, - unique: self.options.unique - }); - isSelected(pos) && self.$items[pos].addClass('OxSelected'); - self.$items[pos].appendTo(self.$pages[page]); - }); - page == 0 && fillFirstPage(); - // FIXME: why does emptyPage sometimes have no methods? - //Ox.Log('List', 'emptyPage', $emptyPage) - $emptyPage && $emptyPage.remove && $emptyPage.remove(); - self.$pages[page].appendTo(that.$content); - !Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event? - })); - } else { - //Ox.Log('List', 'loading a page from cache, this should probably not happen -----------') - self.$pages[page].appendTo(that.$content); + + if (!Ox.isUndefined(self.$pages[page])) { + Ox.Log('List', 'fixme: unload should have made this undefined already'); } + + self.$pages[page] = constructEmptyPage(page); + page == 0 && fillFirstPage(); + self.$pages[page].appendTo(that.$content); + self.requests.push(self.options.items({ + keys: keys, + query: self.options.query, + range: range, + sort: self.options.sort + }, function(result) { + var $emptyPage = self.$pages[page]; + self.$pages[page] = $('
').addClass('OxPage').css(getPageCSS(page)); + result.data.items.forEach(function(v, i) { + var pos = offset + i; + self.$items[pos] = Ox.ListItem({ + construct: self.options.construct, + data: v, + //format: self.options.format, + position: pos, + unique: self.options.unique + }); + isSelected(pos) && self.$items[pos].addClass('OxSelected'); + self.$items[pos].appendTo(self.$pages[page]); + }); + page == 0 && fillFirstPage(); + // FIXME: why does emptyPage sometimes have no methods? + //Ox.Log('List', 'emptyPage', $emptyPage) + $emptyPage && $emptyPage.remove && $emptyPage.remove(); + self.$pages[page].appendTo(that.$content); + !Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event? + })); } function loadPages(page, callback) { - Ox.Log('List', 'loadPages', page) + Ox.Log('List', 'loadPages', page); var counter = 0, fn = function() { if (++counter == 3) { @@ -1409,7 +1409,6 @@ Ox.List = function(options, self) { function updateQuery(callback) { // fixme: shouldn't this be setQuery? var data; - clear(); // fixme: bad function name ... clear what? self.requests.push(data = self.options.items({ query: self.options.query }, function(result) { @@ -1418,6 +1417,7 @@ Ox.List = function(options, self) { // will reach here before one can bind to the init event, // and before any sizes can be determined via the DOM setTimeout(function() { + clear(); // fixme: bad function name ... clear what? that.triggerEvent( 'init', Ox.extend(