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 ?
A Backbone. js Collections are a group of related models. It is useful when the model is loading to the server or saving to the server. Collections also provide a helper function for performing computation against a list of models.
Backbone. Backbone has been around for a long time, but it's still under steady and regular development. It's a good choice if you want a flexible JavaScript framework with a simple model for representing data and getting it into views.
Backend Synchronization BackboneJS is use with the front-end and back-end systems, allows the synchronization with the backend to provide support to RESTful APIs.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With