15

I'm trying to render only the first 20 items in a backbonejs collection.

If the collection was an array I would do _.first(collection, 20). But since it's not it doesn't work. How do I limit it to 20? Thanks.

Harry
  • 52,711
  • 71
  • 177
  • 261

1 Answers1

22

Backbone collections have underscore methods builtin:

collection.first(20)
Otto Allmendinger
  • 27,448
  • 7
  • 68
  • 79
  • 4
    @Harry you can, but not easily... try this underscore method: http://documentcloud.github.com/underscore/#chain – Sander Nov 23 '11 at 20:06