DocumentCloud is a small (2KB, packed)
open-source library which allows you to apply the MVC
preventing you from having to tie data directly to the DOM. When models
change, the views representing the data can be notified, causing them to
To define a model, you extend
Backbone.Model with your own
properties and methods, and the framework provides ways to get and set
the attributes, set up validations, serialize the object, detect if it
has changed, etc. To save a valid model to the persistence layer,
Backbone will delegate to its
sync function and make a
relevant RESTful request (using JSON by default) to the server.
Backbone proxies to DocumentCloud's
underscore library for dealing with collections of models.
For views, create a custom view class which extends
Backbone.view, and then instantiate it, passing some
options which can include the model, a collection, the HTML element,
etc... You can define a
render function on the view to
setup the view (with whatever flavour of templating or DOM manipulation
you like), and this can be bound to model events.
The documentation is well
written and comprehensive, providing good examples, and there's a
test-suite too. Get the code on