 
   fetchCategories: (payload) ->
     $.each payload, (index, item) =>
-      this.addCategory(item)
+      @addCategory(item)
 
   addCategory: (category) ->
     @category_editors.push new CategoryEditor(@node, category)
 
   save: ->
-    payload = { product_id: @product_id, product_categories: this.serialize() }
+    payload = { product_id: @product_id, product_categories: @serialize() }
     $.ajax
       type: 'POST'
       dataType: 'json'

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

    this.fetchCategories(payload)

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

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

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

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

    @node.find(".js-val").val()

  serialize: ->
    { key: @key(), value: @value() }
