diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index ba575e06..dbc1287f 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -407,20 +407,27 @@ Ox.ListMap = function(options, self) { place.countryCode = country ? country.code : ''; self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe? place.id = self.selectedPlace; - self.options.places.push(place); - //self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place; + if (Ox.isArray(self.options.place)) { + self.options.places.push(place); + self.$list.options({ + items: Ox.clone(self.options.places), + selected: [place.id] + }); + setStatus(); + } self.$map.addPlace(place); - self.$list.options({items: Ox.clone(self.options.places)}); - self.$list.options({selected: [place.id]}); - setStatus(); - self.$placeButton.options({title: 'Remove Place'}) + self.$placeButton.options({title: 'Remove Place'}); + that.triggerEvent('addplace', {place: place}); } else if (title == 'Remove Place') { var index = Ox.getPositionById(self.options.places, self.selectedPlace); - self.options.places.splice(index, 1); - self.$list.options({items: Ox.clone(self.options.places)}); - setStatus(); + if (Ox.isArray(self.options.place)) { + 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', {place: place}); } Ox.print('PLACES.LENGTH', self.options.places.length) Ox.print('ITEMS.LENGTH', self.$list.options('items').length)