Last active
October 6, 2015 14:56
-
-
Save pieterbeulque/ac32049370f174b92cab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ids = [1, 2, 3, 4], | |
details = [], | |
fetch = function (id) { | |
var dfd = new $.Deferred(); | |
new Request({ id: id }, function (res) { | |
dfd.resolve(res); | |
}); | |
return dfd.promise(); | |
}; | |
for (var i = 0; i < ids.length; i++) { | |
details.push(fetch(ids[i])); | |
} | |
$.when.apply($, details).then(function () { | |
for (var i = 0; i < arguments.length; i++) { | |
var detail = arguments[i]; | |
console.log(detail); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment