-
• #2
You need to use
bla.init.bind(bla)
orfunction(){bla.init()}
, not justbla.init
.It's one of the 'gotchas' of JavaScript, and it's the same thing that happens for
setInterval
,setTimeout
, or any callback.Basically, when you call a function, like
bla.init()
, thethis
variable gets set up tobla
. However, if you just passbla.init
, you're basically doing this:var x = bla.init; x();
In that case,
x
is just a function, that has no association withbla
at all - so when you call it,this
isn't set. -
• #3
thanks !
what is wrong with my sample code - any comments ?
online with WEB IDE
with E.on(): Uncaught Error.....