         Session.set("tagging_#{ @_id }", false)
         event.stopImmediatePropagation()
   }
+  
+  add_tag: (id, grad_tags, my_tags, tag_text, text_box) =>
+    console.log(_this)
+    if tag_text != "" && not my_tags[tag_text]?
+      #TODO: add to my_tags not grad_tags
+      grad_tags[tag_text] ?= { users: [], weight: 0}
+      grad_tags[tag_text].users.push(Session.get('user_id'))
+      Posts.update(id, {$set: {tags: grad_tags}})
+      #clear textbox and update suggestion filter
+      text_box.value = ''
+      Session.set("filter_text_#{ id }", '')
+      Session.get("context_#{ id }").invalidate()
 )
 
 Handlebars.registerHelper('vis_tags', (context, object) ->
-  @my_tags = {test: 0}          #TODO: REMOVE
+  @my_tags = {}          #TODO: REMOVE
   ret = ""
   for tag in context
     ret += "<div class='tag"

        
        switch event.keyCode
          when 13 #Enter
            ###TODO: Encapsulate this code so the click event calls it too
            if entered_text != "" #TODO: && not @my_tags[tag_text]?
              #TODO: add to @my_tags not @tags
              @tags[entered_text] ?= { users: [], weight: 0}
              @tags[entered_text].users.push(Session.get('user_id'))
              Posts.update(@_id, {$set: {tags: @tags}})
              #clear textbox and update suggestion filter
              event.target.value = ''
              Session.set("filter_text_#{ @_id }", '')
              Session.get("context_#{@_id}").invalidate()
            ###
            #Does this work?  It encapsulates the code pretty well
            #$("button[name='enter_tag']").click()
            Template.tagbox.add_tag(@tags, entered_text, event, @_id)
          when 37 #Left-arrow: ADD
            if suggested_tag?
              @tags[suggested_tag] ?= { users: [], weight: 0}

# -'TODO's indicate case-specific changes
###
_.extend( Template.tagbox,
  visible_tags: ->
    visible = (tag for tag of @tags)  #graduated tags
    @my_tags ?= {}                    #TODO: REMOVE on schema change
