 
           layer.setStyle(this.setFeatureStyle(layer.feature))
 
+          layer.closePopup()
+
           #update popup
           this.popupize layer.feature, layer
 
           $(this.element).trigger('mapeditor:feature_update', layer.feature)
-
-          layer.closePopup()
-
 
         false
 


    popupize: (feature, layer) ->
      popup = ""
      popup += "<div class='popup-content'>"
      id = if feature.properties.id? then "#{feature.properties.id}: " else ''
      popup += "<span class='popup-block-content' data-internal-id='#{feature.properties.internal_id}'>#{id}#{feature.properties.name || this.options.defaultLabel}</span>"
      popup += "<span class='warning right hide'></span>"


      if this.options.multiLevels?
        popup += "<select>"

        for level in [parseInt(@options.multiLevels.maxLevel)..parseInt(@options.multiLevels.minLevel)]
          selected = ""

          if level == parseInt(feature.properties.level)
            selected = "selected"

          #TODO i18n this
          label = if level == 0 then 'RDC' else "#{@options.multiLevels.levelLabel} #{level}"

          popup += "<option value='#{level}' #{selected}>#{label}</option>"

        popup += "</select>"

      popup += "<input class='updateAttributesInPopup' type='button' value='ok'/>"
      popup += "</div>"

      layer.bindPopup popup, keepInView: true, maxWidth: 600

    colorize: (level) ->
      #levels rane is set to [-3,3]
