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);
var pos = 0;
if (result) {
$.extend(self, {
positions: {},
selected: []
});
self.options.selected = [];
self.positions = {};
self.selected = [];
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);
});
pos = Ox.min(self.selected);
self.page = getPageByPosition(pos);
if (self.selected.length) {
pos = Ox.min(self.selected);
self.page = getPageByPosition(pos);
}
} else if (self.stayAtPosition) {
self.page = getPageByScrollPosition(self.stayAtPosition);
}
@ -726,6 +730,7 @@ Ox.List = function(options, self) {
}
function loadPages(page, callback) {
Ox.print('loadPages', page)
var counter = 0,
fn = function() {
if (++counter == 3) {