I have a situation (using the Raphael library) where I have this:
rect.click(doSomething);
And within doSomething(), I can get the bounding box size:
var boxSize = this.getBBox();
The problem is, what if I want to pass an argument to doSomething? If I do, then the this reference breaks for some reason. How can I pass in an argument and still use this?
You can wrap the listener in another function, and use
.call()to call the function with given parameters: