 
   serialize: ->
     {
-      name: this.name(),
+      name: @name(),
       properties: @properties.map (p) -> p.serialize()
     }
 


    if @category.properties
      $.each @category.properties, (index, item) =>
        this.addProperty(item)

    @property_rows.on 'deleteProperty', (ev, property) =>
      this.propertyDeleted(property)

    @add_property_button.click =>
      this.addProperty({key: '', value: ''})

    @delete_button.click =>
      @parent.trigger 'deleteCategory', this

  constructor: (@node, payload, @product_id) ->
    @category_editors = []

    @fetchCategories(payload)

    @node.on 'click', '.add-category', =>
      @addCategory({name: 'New Category'})

    @node.on 'click', '.save', =>
      @save()

    @node.on 'deleteCategory', (ev, category) =>
      @categoryDeleted(category)

  categoryDeleted: (category) ->
    category.node.remove()
