   constructor: (@node, payload, @product_id) ->
     @category_editors = []
 
-    this.fetchCategories(payload)
+    @fetchCategories(payload)
 
     @node.on 'click', '.add-category', =>
-      this.addCategory({name: 'New Category'})
+      @addCategory({name: 'New Category'})
 
     @node.on 'click', '.save', =>
-      this.save()
+      @save()
 
     @node.on 'deleteCategory', (ev, category) =>
-      this.categoryDeleted(category)
+      @categoryDeleted(category)
 
   categoryDeleted: (category) ->
     category.node.remove()


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



  fetchCategories: (payload) ->
    $.each payload, (index, item) =>
      @addCategory(item)

  addCategory: (category) ->
    @category_editors.push new CategoryEditor(@node, category)

  save: ->
    payload = { product_id: @product_id, product_categories: @serialize() }
    $.ajax
      type: 'POST'
      dataType: 'json'
