Skip to content

Instantly share code, notes, and snippets.

@knwang
Created May 17, 2012 17:12
Show Gist options
  • Save knwang/2720266 to your computer and use it in GitHub Desktop.
Save knwang/2720266 to your computer and use it in GitHub Desktop.
hugarocketeer javascript 3
....
returned_results: 0,
initialize: function() {
var self = this;
this.collection = new People();
_.each(rocketeers, function(person) {
$.getJSON(person.get("search_url"), function(data) {
var hugs = data.results.length;
person.set({hugs: hugs});
self.collection.add(person);
self.returned_results += 1;
if (self.returned_results == rocketeers.length) {
self.render();
}
})
});
_.bindAll(this, 'render');
},
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment