Skip to content

Instantly share code, notes, and snippets.

@nhajratw
Created December 12, 2011 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhajratw/1468043 to your computer and use it in GitHub Desktop.
Save nhajratw/1468043 to your computer and use it in GitHub Desktop.
Trying to iterate through a Backbone.Collection
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?
@nhajratw
Copy link
Author

Solved by using underscore methods .. i.e.

@offers.each(offer) => @callme(offer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment