Skip to content

Instantly share code, notes, and snippets.

@mplatts
Last active August 29, 2015 14:10
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/429f8a32acb48c25fef5 to your computer and use it in GitHub Desktop.
Save mplatts/429f8a32acb48c25fef5 to your computer and use it in GitHub Desktop.
templates2 - create game method
# client/views/games.coffee
Template.games.helpers
teams: Teams.find()
games: Games.find()
creating: -> Session.get 'creating-game'
Template.games.events
"click .create": (e, tpl) ->
e.preventDefault()
Session.set 'creating-game', true
"click .cancel": (e, tpl) ->
e.preventDefault()
Session.set 'creating-game', null
"submit form.form-create": (e, tpl) ->
e.preventDefault()
teamOneId = tpl.$("select[name='teamOne']").val()
teamTwoId = tpl.$("select[name='teamTwo']").val()
Meteor.call 'gamesInsert', teamOneId, teamTwoId, (error, id) ->
if error
return alert error.error
Session.set 'creating-game', false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment