With Backbone, data is represented as Models, which can be created, validated, destroyed, and saved to the server. Whenever a UI action causes an attribute of a model to change, the model triggers a “change” event; all the Views that display the model’s state can be notified of the change, so that they are able to respond accordingly, re-rendering themselves with the new information. In a finished Backbone app, we don’t have to write the glue code that looks into the DOM to find an element with a specific id, and update the HTML manually — when the model changes, the views simply update themselves.
It’s easy to create small and slick web applications with frameworks like jQuery. When a project grows, however, the jQuery declarations and callbacks get more and more complex and are distributed all over the place. The code becomes more and more cluttered and hard to read.
Backbone.js alleviates this by providing an event-driven communication between views and models (and other elements which we ignore for now for the sake of simplicity). One can attach event listeners to any attribute of a model, which gives control over change in the view.
The backbone.js events build on top of regular DOM events, which make the mechanism very versatile and extensible.
3 major advantages:
1. When a project grows, the jQuery declarations and callbacks gets more complex. The code becomes more cluttered. Backbone.js overcomes this problem by providing an event-driven communication between views and models.
3. In the MVC platform, web application depends upon server for getting json data for the logic on how to display it. Here load on server is reduced and it helps in increasing the speed of the website.
Backbone also offers a “sync” utility that can persist the model back to the server (provided server is RESTful). For example, this can work quite nicely with a standard Rails CRUD app.
Another advantage of using any framework is maintainability. Bringing on other devices becomes easier, because they can follow the pattern and, thus, follow our code.