Created
September 25, 2011 16:33
-
-
Save lucagrulla/1240807 to your computer and use it in GitHub Desktop.
blog post: Javascript flow control
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
function fecthData() { | |
var people = ["Marc", "Liz", "Ken", "Duncan", "Uday", "Mark", "Charles"]; | |
var grid = []; | |
$.each(people, function(index, person) { | |
$.getJSON('/git/pairs/' + person, function(data) { | |
// parse data and create somethingCool | |
grid.push(data["name"]) | |
if (grid.length === people.length) { | |
$(document).trigger("gridFilled", [grid]); | |
} | |
}); | |
}); | |
} | |
$(document).bind("gridFilled", function(e, grid) { | |
//ready to do something with grid ! | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment