Problem with Deferreds -- Adding Custom Deferred Object to Array
I am trying to learn how to create custom Deferred objects and am working on the following:
http://jsfiddle.net/jhYjw/7/
Something must be up with jsFiddle, but when I run that code on my local browser, everything seems to work.
The deferreds are all called then the .done() is 开发者_如何学运维called.
However, there are no arguments passed in to the .done(). It's [] "result" in undefined.
What's going on? :P I'm passing in a string to resolveWith()
Thanks SO!
.resolveWith(x)
[docs] doesn't pass x
to your callbacks. It runs your callbacks with this
set to x
.
To pass x
as the argument of your callback function use .resolve(x)
[docs], or .resolveWith(valueForThis, x)
.
精彩评论