     $scope.orFilter = []
   , true)
 
-  $scope.$watch('itemSetBlocks', () ->
+  # sends an ajax request to the rails web server to
+  # sync the current item set to the ones stored
+  # on the rails server
+  $scope.updateItemSet = () ->
     obj = buildJSON($scope.itemSetBlocks, $scope.mapOption, $scope.selectedMap)
     console.log(obj)
     data =

        # if there is no associated maps, then we can use
        # this item set for ANY maps, hence the mapOption is
        # set to 1
        $scope.mapOption = 1
      else
        # if there is any associated maps, it means
        # we can only choose a specific map, and not any map
        # hence mapOption is set to 0
        $scope.mapOption = 0
        $scope.selectedMap = gon.setData.associatedMaps[0]

      for itemBlock in gon.setData.blocks


buildJSON = (blockData, mapOption, selectedMap) ->
  exportObj = {}
  if mapOption == '0'
    # if map option is zero, then we have to have a selected map
    exportObj.associatedMaps = [selectedMap]
  else
