Forgive my ignorance as I am not as familiar with jquery. Is there an equivalent to dojo.hitch()? It returns a function that is guaranteed to be executed in the given scope.
[ADMIN EDIT: Note the much more popular answer, below.—danorton]
I'd go for function.bind
, which will be the standard way of doing this in future versions of JavaScript. As well as fixing this
, it allows you to pass arguments through to the target functions.
Until all browsers support it natively, you can hack support in yourself.