From 0ca93fcebe1184d33c63ed2f8220a728c3ba05e1 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 2 Oct 2011 17:05:56 +0000 Subject: [PATCH] fix a bug in listmap, regarding removal of places --- source/Ox.UI/js/List/Ox.List.js | 6 +++++- source/Ox.UI/js/Map/Ox.ListMap.js | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index ac046178..55c38fef 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -569,6 +569,7 @@ Ox.List = function(options, self) { // fixme: is this really needed? var pos = -1; 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) { pos = i; return false; @@ -1656,6 +1657,7 @@ Ox.List = function(options, self) { var pos = Ox.isNumber(id) ? id : getPositionById(id), $item = self.$items[pos], data = $item.options('data'); + Ox.print('((((()))))', id, pos) if (arguments.length == 1) { return data; } else if (arguments.length == 2) { @@ -1667,7 +1669,9 @@ Ox.List = function(options, self) { return id_ == data[key] ? value : id_ }); } - self.options.items[pos][key] = value; + if (!self.isAsync) { + self.options.items[pos][key] = value; + } data[key] = value; $item.options({data: data}); return that; diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index e826fde6..6d6ec226 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -682,21 +682,23 @@ Ox.ListMap = function(options, self) { } function removePlace() { - var index = Ox.getPositionById(self.options.places, self.selectedPlace); + var index; + Ox.print('REMOVE PLACE', self.selectedPlace, index) if (!self.isAsync) { + index = Ox.getPositionById(self.options.places, self.selectedPlace); self.options.places.splice(index, 1); self.$list.options({items: Ox.clone(self.options.places)}); //setStatus(); } - self.$map.removePlace(); - self.$placeButton.options({title: 'Add Place'}); - that.triggerEvent('removeplace', {id: self.selectedPlace}); + // fixme: what is this? both options.removePlace and event removeplace?? if (self.isAsync) { self.options.removePlace({id: self.selectedPlace}, function() { self.$list.options({selected: []}).reloadList(true); }); } - + self.$map.removePlace(); + self.$placeButton.options({title: 'Add Place'}); + that.triggerEvent('removeplace', {id: self.selectedPlace}); } function initList(data) {