So I've been playing around with backbone.js. And I have to say I love it.
First thing I noticed is how little backbone does. It is actually quite small. Sure it does a few things about object creation, constructors, initialization behavior, but that's really it.
The biggest strength is data binding events. "change:foo" event fires when the foo attribute changes. On a collection add/remove/reset events fire. This is powerful. Not to mention custom events.
This basically means that all you need to do is wire everything correctly, have a view render your collection/model, bind appropriately, and boom the entire page changes whenever the model is updated.
One thing I've been implementing is this filtering model
https://github.com/dlikhten/filtered-collection
https://github.com/dlikhten/paginated-collection
The big advantage here is that I set up a chain of filters, and just update them independently, and the displayed elements just update.
In my setup I have the following:
a main collection (main)
a filter on main (f1)
a filter on f1 (f2)
a filter on f2 (f3)
a pagination on f3 (p1)
I give p1 to a view which renders all the elements (data view).
f1 is given to a view to apply f1 filters (f1 view)
f2 is given to a view to apply f2 filters (f2 view)
f3 is given to a view to apply f3 filters (f3 view)
p1 is given to a pagination view which renders page #s, clicking on a page # will tell p1 to change itself to the given page (p1 view)
now I have power
I don't need to do anything else. Data view will react to things like add/remove/reset events that data/f1-f3/p1 trigger. So whenever stuff happens data view will just re-render.
Since the events trickle down (if f1 is filtered, f2 filters, then f3, then p1 etc) I don't care which filer gets modified and when, it just all renders correctly. Furthermore p1 view does not need to track which page we are on. When p1 notifies of it's own changes, p1 view just re-renders with the new total number of pages and vuala pagination auto updates.
Just wire once and stop worrying. That's backbone's motto (it seems). I am sure I will hit performance issues sooner or later, maybe not :P