Last active
April 6, 2016 08:15
-
-
Save HituziANDO/6909d8dc8ccf1f7bcec30b78f8b23435 to your computer and use it in GitHub Desktop.
jQuery.whenにQ.allのように配列でDeferredを渡す方法
This file contains 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
/** | |
* jQuery.whenにQ.allのように配列でDeferredを渡す関数 | |
* | |
* @param deferredList Array of jQuery.Deferred object | |
* @returns jQuery.Promise object | |
*/ | |
function $all(deferredList) { | |
return $.when.apply(null, deferredList); | |
} | |
// 使い方 | |
// $all([ | |
// $.get('/path/to/data1.json'), | |
// $.get('/path/to/data2.json') | |
// ]).done(function(data1, data2) { | |
// // Do something | |
// }).fail(function() { | |
// // Do something | |
// }).always(function() { | |
// // Do something | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment