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.
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.
12 comments
[ 2.9 ms ] story [ 34.9 ms ] threadvar 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...