我正在尝试为我的模型创建一个自定义事件,但显然自定义事件无论如何都会被触发,除非我使用“匿名”函数定义作为回调
这是我的应用程序结构的伪代码
//Router
initialize: ->
this.user = new User()
this.view = new View({model:this.user})
this.view.render()
//View
initialize: ->
//This event binding get triggered no matter what
//this.model.on("custom:event", this.triggerMe(), this)
//This works properly. Only triggered when I call model.trigger("custom:event")
this.model.on("custom:event", function(){console.log("I WORK!!");}))
triggerMe: ->
//I GET TRIGGER NO MATTER WHAT