Reputation: 262534
What is the standard approach for paged collections in Backbone.js ? And how about sorting ? Does it support these features out of the box ? Do I need some sort of plugin ?
Upvotes: 5
Views: 3926
Reputation: 4791
None of these things are supported out of the box (Backbone is a thin library, not a big framework).
For pagination check Backbone JS Pagination
For sorting, the think you have in Backbone is defining a comparator on a collection: http://documentcloud.github.com/backbone/docs/backbone.html#section-53
So one approach would be to initialize your collection, and then when you have to change the order, change it's comparator and call collection.sort. This would trigger a reset
event that you can listen for in your view and re-render.
Upvotes: 6