Looking for elegant solution to a common problem:
I got a class that subscribe to few events, I want the handler to be an instance method inside my class, but also want to get the event context(the element the event fired on for this case)
so I'm using the fat line syntax for the method definition but got no way to get the event context. To be concrete I'm using raphael js and when subscribing on element the event object does not contain the element, only the dom element so without the event context I'll have to search the element by it's raphael id inside the paper, and I don't like it.
What is the best practice in this case? I'm currently creating a new context object before each time I subscribe to the event, the context contains the instance reference and the element reference.
Thursday, April 12, 2012
Coffee script - preserve the class context and the event context
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment