Reference Object calling function in Javascript

Posted by Louis on Stack Overflow See other posts from Stack Overflow or by Louis
Published on 2010-05-25T06:10:30Z Indexed on 2010/05/25 6:21 UTC
Read the original article Hit count: 236

Filed under:
|
|

I have a makeshift events system in JS and the attacher looks like this:

events.attach(events.NEW_TASK,this.update);

Where this.update is a callback/handler/function. The problem is, when the dispatcher tries to call this handler, it loses it's original context. How can I bind the handler with the context of the object that calls the attach function without passing this as an argument and using that?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about events