fix setting items and sort at the same time

This commit is contained in:
j 2014-02-07 08:37:46 +00:00
parent ddb6165a76
commit 45155f1f71

View file

@ -833,7 +833,11 @@ Ox.List = function(options, self) {
var keys = Ox.unique(self.options.keys.concat(self.options.unique)), var keys = Ox.unique(self.options.keys.concat(self.options.unique)),
offset = page * self.pageLength, offset = page * self.pageLength,
range = [offset, offset + getPageLength(page)]; range = [offset, offset + getPageLength(page)];
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
if (!Ox.isUndefined(self.$pages[page])) {
Ox.Log('List', 'fixme: unload should have made this undefined already');
}
self.$pages[page] = constructEmptyPage(page); self.$pages[page] = constructEmptyPage(page);
page == 0 && fillFirstPage(); page == 0 && fillFirstPage();
self.$pages[page].appendTo(that.$content); self.$pages[page].appendTo(that.$content);
@ -864,14 +868,10 @@ Ox.List = function(options, self) {
self.$pages[page].appendTo(that.$content); self.$pages[page].appendTo(that.$content);
!Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event? !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);
}
} }
function loadPages(page, callback) { function loadPages(page, callback) {
Ox.Log('List', 'loadPages', page) Ox.Log('List', 'loadPages', page);
var counter = 0, var counter = 0,
fn = function() { fn = function() {
if (++counter == 3) { if (++counter == 3) {
@ -1409,7 +1409,6 @@ Ox.List = function(options, self) {
function updateQuery(callback) { // fixme: shouldn't this be setQuery? function updateQuery(callback) { // fixme: shouldn't this be setQuery?
var data; var data;
clear(); // fixme: bad function name ... clear what?
self.requests.push(data = self.options.items({ self.requests.push(data = self.options.items({
query: self.options.query query: self.options.query
}, function(result) { }, function(result) {
@ -1418,6 +1417,7 @@ Ox.List = function(options, self) {
// will reach here before one can bind to the init event, // will reach here before one can bind to the init event,
// and before any sizes can be determined via the DOM // and before any sizes can be determined via the DOM
setTimeout(function() { setTimeout(function() {
clear(); // fixme: bad function name ... clear what?
that.triggerEvent( that.triggerEvent(
'init', 'init',
Ox.extend( Ox.extend(