I'm trying to use CoffeeScript with Backbone.js (via Brunch) and I want to implement a save function in my model, but it refuses to compile and I have been unable to figure out why. I need to both pass parameters into the save function and implement callbacks.
The code below gives an Unexpected ':' error on the second line, but I'm not sure why:
class exports.Tag extends Backbone.model
defaults:
id: null
tagId: null
found: false
location: "Not yet found..."
finders: []
pointValue: 0
unlockCode: ""
verifyCode = ( code ) ->
@save { tagId: @get 'tagId', unlockCode: code },
success: ( model, response ) ->
@trigger 'verifySuccessful', response
error: ( model, response ) ->
@trigger 'verifyFailed', response
Any help appreciated...thanks!