 
 populateCategories = (element) ->
   for {id, description} in data.categories
-    element.append "<option value='#{id}'>#{description}</option>"
+    element.append """<option value="#{id}">#{description}</option>"""
 
 populateItems = (category_id, element) ->
   id = parseInt category_id

    if category.id is id
      currentCategory = category
  element.empty()
  element.append '<option value="">Select an item...</option>'
  for {id, description} in currentCategory.items
    element.append "<option value='#{id}'>#{description}</option>"

findLastCategory = ->
  orders = $('.well').find '.order'
  $(orders[orders.length-1]).find '#category'

$(document).on "click", ".add-item", (e) ->
  e.preventDefault()

  $("#add_inventory_modal").modal("show")

$(document).on "click", "#add-item-row", (event) ->
  event.preventDefault()
  addNewOrderRow()

$(document).on "change", ".new-order-row .category", ->
  item_element = $(@).parents(".new-order-row").find ".item"
  populateItems $(@).val(), item_element

$(document).on "page:change", ->
  addNewOrderRow() if $("#new-order-table").length > 0

