fix a bug in listmap, regarding removal of places

This commit is contained in:
rlx 2011-10-02 17:05:56 +00:00
parent 13e52cdca7
commit 0ca93fcebe
2 changed files with 12 additions and 6 deletions

View file

@ -569,6 +569,7 @@ Ox.List = function(options, self) {
// fixme: is this really needed? // fixme: is this really needed?
var pos = -1; var pos = -1;
Ox.forEach(self.$items, function($item, i) { Ox.forEach(self.$items, function($item, i) {
//Ox.print('$item', i, self.options.unique, $item.options('data')[self.options.unique])
if ($item.options('data')[self.options.unique] == id) { if ($item.options('data')[self.options.unique] == id) {
pos = i; pos = i;
return false; return false;
@ -1656,6 +1657,7 @@ Ox.List = function(options, self) {
var pos = Ox.isNumber(id) ? id : getPositionById(id), var pos = Ox.isNumber(id) ? id : getPositionById(id),
$item = self.$items[pos], $item = self.$items[pos],
data = $item.options('data'); data = $item.options('data');
Ox.print('((((()))))', id, pos)
if (arguments.length == 1) { if (arguments.length == 1) {
return data; return data;
} else if (arguments.length == 2) { } else if (arguments.length == 2) {
@ -1667,7 +1669,9 @@ Ox.List = function(options, self) {
return id_ == data[key] ? value : id_ return id_ == data[key] ? value : id_
}); });
} }
self.options.items[pos][key] = value; if (!self.isAsync) {
self.options.items[pos][key] = value;
}
data[key] = value; data[key] = value;
$item.options({data: data}); $item.options({data: data});
return that; return that;

View file

@ -682,21 +682,23 @@ Ox.ListMap = function(options, self) {
} }
function removePlace() { function removePlace() {
var index = Ox.getPositionById(self.options.places, self.selectedPlace); var index;
Ox.print('REMOVE PLACE', self.selectedPlace, index)
if (!self.isAsync) { if (!self.isAsync) {
index = Ox.getPositionById(self.options.places, self.selectedPlace);
self.options.places.splice(index, 1); self.options.places.splice(index, 1);
self.$list.options({items: Ox.clone(self.options.places)}); self.$list.options({items: Ox.clone(self.options.places)});
//setStatus(); //setStatus();
} }
self.$map.removePlace(); // fixme: what is this? both options.removePlace and event removeplace??
self.$placeButton.options({title: 'Add Place'});
that.triggerEvent('removeplace', {id: self.selectedPlace});
if (self.isAsync) { if (self.isAsync) {
self.options.removePlace({id: self.selectedPlace}, function() { self.options.removePlace({id: self.selectedPlace}, function() {
self.$list.options({selected: []}).reloadList(true); self.$list.options({selected: []}).reloadList(true);
}); });
} }
self.$map.removePlace();
self.$placeButton.options({title: 'Add Place'});
that.triggerEvent('removeplace', {id: self.selectedPlace});
} }
function initList(data) { function initList(data) {