Re:
by DCoder on Monday March 07, 2011 @12:40AM
(#2296172)
I don't think you're doing this right. The first .then receives a function, but the second .then executes function.apply at construction time and receives only its result (null) as the callback.
Re:
by joske2 on Monday March 07, 2011 @12:48AM
(#2296193)
In ES5 you have Function.prototype.bind that returns a new function with this bound to whatever you want. You can also pass extra default arguments. On older browsers you could use es5-shim for this functionality.
var self = this; function(){ self.foo() }
heh.
Also, after understanding what's going on, existing solutions might be better than rolling your own: http://api.jquery.com/jQuery.proxy/ .
See https://developer.mozilla.org/en/JavaScript/Reference/Global...