fix setting items and sort at the same time
This commit is contained in:
parent
ddb6165a76
commit
45155f1f71
1 changed files with 37 additions and 37 deletions
|
@ -103,7 +103,7 @@ Ox.List = function(options, self) {
|
||||||
sort: self.options.sort,
|
sort: self.options.sort,
|
||||||
sums: self.options.sums,
|
sums: self.options.sums,
|
||||||
unique: self.options.unique
|
unique: self.options.unique
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
self.listLength = self.options.items.length;
|
self.listLength = self.options.items.length;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
|
@ -833,45 +833,45 @@ 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
|
|
||||||
self.$pages[page] = constructEmptyPage(page);
|
if (!Ox.isUndefined(self.$pages[page])) {
|
||||||
page == 0 && fillFirstPage();
|
Ox.Log('List', 'fixme: unload should have made this undefined already');
|
||||||
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] = $('<div>').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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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] = $('<div>').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) {
|
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(
|
||||||
|
|
Loading…
Reference in a new issue