Skip to content

Instantly share code, notes, and snippets.

@mplatts
Created November 18, 2014 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mplatts/6f1c3c8204c2a204b7e4 to your computer and use it in GitHub Desktop.
Save mplatts/6f1c3c8204c2a204b7e4 to your computer and use it in GitHub Desktop.
events 5
# client/views/team.coffee
Template.team.helpers
editing: -> Session.get('editing') == @_id
Template.team.events
"click .edit": (e, tpl) ->
e.preventDefault()
Session.set('editing', @_id)
"submit form.form-edit": (e, tpl) ->
e.preventDefault()
teamName = tpl.$("input[name='name']").val()
if teamName.length
Teams.update(@_id, $set: {name: teamName})
Session.set('editing', null)
"click .cancel": (e, tpl) ->
e.preventDefault()
Session.set('editing', null)
"click .remove": (e, tpl) ->
e.preventDefault()
Teams.remove(@_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment