make sure list can handle a selected id option that is not in the results

This commit is contained in:
rlx 2011-08-17 20:07:53 +00:00
parent 91c69d5d23
commit 19aa9b40e5

View file

@ -586,15 +586,19 @@ Ox.List = function(options, self) {
//Ox.print('getPositionsCallback', result); //Ox.print('getPositionsCallback', result);
var pos = 0; var pos = 0;
if (result) { if (result) {
$.extend(self, { self.options.selected = [];
positions: {}, self.positions = {};
selected: [] self.selected = [];
});
Ox.forEach(result.data.positions, function(pos, id) { Ox.forEach(result.data.positions, function(pos, id) {
// fixme: in case the order of self.options.selected
// is important - it may get lost here
self.options.selected.push(id);
self.selected.push(pos); self.selected.push(pos);
}); });
pos = Ox.min(self.selected); if (self.selected.length) {
self.page = getPageByPosition(pos); pos = Ox.min(self.selected);
self.page = getPageByPosition(pos);
}
} else if (self.stayAtPosition) { } else if (self.stayAtPosition) {
self.page = getPageByScrollPosition(self.stayAtPosition); self.page = getPageByScrollPosition(self.stayAtPosition);
} }
@ -726,6 +730,7 @@ Ox.List = function(options, self) {
} }
function loadPages(page, callback) { function loadPages(page, callback) {
Ox.print('loadPages', page)
var counter = 0, var counter = 0,
fn = function() { fn = function() {
if (++counter == 3) { if (++counter == 3) {