Hi I'm new to Js and Coffeescript, here's a situation I feel difficult to refer the property of parent object which is App
in the following example
App =
init: ->
this.foo = 'bar'
this.bindEvent()
bindEvent: ->
$('#test').click(this.show)
show: ->
alert this.foo
App.init()
I think the fat arrow may do the trick but once I've changed to show: =>
, this
in the context of show
method refers to the window object, instead of App
object that I want to
. Anybody can tell me how to do it right?