 
           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
 


      if this.options.multiLevels?
        popup += "<select>"
        for level in [parseInt(this.options.multiLevels.minLevel)..parseInt(this.options.multiLevels.maxLevel)]
          selected = ""
          if level == parseInt(feature.properties.level)
            selected = "selected"

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

        popup += "</select>"

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

      layer.bindPopup popup

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

        html += "<div class='leaflet-legend-body leaflet-multilevel-legend' data-level='#{level}'>"

        color = this.colorize(level)

        label = if level == 0 then 'RDC' else "#{this.options.defaultLevelLabel} #{level}"

        html += "<i class='active' style='background-color: #{color}' title='#{label}'></i>"
        html += "<span>#{label}</span>"
        html += "</div>"
        html += "</div>"

