Created
December 12, 2011 16:10
-
-
Save nhajratw/1468043 to your computer and use it in GitHub Desktop.
Trying to iterate through a Backbone.Collection
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
I have a model: | |
class Offer extends Backbone.Model | |
And a Collection: | |
class Offers extends Backbone.Collection | |
model: Offer | |
initialize: -> | |
@add(new Offer) | |
@add(new Offer) | |
Now I want to call a method for each element in the collection: | |
@offers = new Offers | |
@callMe(offer) for offer in @offers | |
This doesn't appear to work .. any ideas? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved by using underscore methods .. i.e.
@offers.each(offer) => @callme(offer)