I have the following code for one of my backbone views:
class GD.Views.Result extends Backbone.View
template: JST['mobile/templates/result']
tagName: 'tr'
className: 'result'
events:
'click' : 'showDetail'
'click #favourite' : 'addFavourite(Favourite)'
'click #like' : 'addFavourite(Like)'
'click #dislike' : 'addFavourite(Dislike)'
render: ->
$(@el).html(@template(model: @model))
this
addFavourite: (type) ->
event.preventDefault()
attributes =
id: @model.id
type: type
cluster: @model.cluster
@collection.create attributes,
wait: true
success: @updateIcons
error: @handleError
showDetail: ->
...
updateIcons: ->
...
handleError: ->
...
And I'm getting this error in my console:
Uncaught Error: Method "addFavourite(Favourite)" does not exist
I don't really understand why this happens for the AddFavourite method and not the showDetail one - are you not allowed to pass methods which require defined arguments to any event?
Many thanks in advance for any help(!)