Created
July 31, 2014 23:02
-
-
Save webjay/fe4ddb5b93e037bc9bbe to your computer and use it in GitHub Desktop.
How to listen to an event on multiple objects using Backbone.js
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 whenAll (objects, event, callback) { | |
var callbackWrapper = _.after(objects.length, callback); | |
_.each(objects, function (obj) { | |
obj.once(event, callbackWrapper, this); | |
}, this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by How to listen to an event on multiple objects using Backbone.js.
I use it like this: