Backbone was created by Jeremy Ashkenas.
Model: It is a part of your code that populates and retrieves the data
View: It is the HTML representation of this model
The main component of Backbone.js are:
Event class object
Models and Collections
Models in Backbone represent data, let’s say I have blog, which contains posts, comments, categories, tags, etc. In this case blog post is a model, category is collection, comment is a model.
Views contain instructions how to render models or collections, once we receive some data from the server – view picks it up, formats it, handles adding new or removing models, etc and passes this information to template (Handlebars, Underscore or any other template engine).
Routers are responsible for navigation. Backbone.js uses HTML5 history API and gracefully degrades in old browsers (you guessed it – Internet Explorer). When building with backbone.js – in most cases you are building one page page application, so there are no page refresh, that’s router’s job. It directs application and where user wants to go. For example if I’m on home page of my blog and need to view single blog post, I click on read more button, router passes this post ID to view, view requests model attached to this view to fetch content from the server and then renders the content to template.
Provides key value binding and custom events
API with tons of functions
Robust event handling
API connetion over a RESTful JSON interface.
A common problem with large JS web application developed is that they can become pretty messy really quickly. The lack of structure makes the code hard to maintain. This is where Backbone comes into play. It provides structure to organize the code and increase maintainability. Backbone is not the only framework like this; in fact, there are many JS frameworks that attempt to offer similar benefits, like Ember.js, Angular.js and so on. Backbone is one of the most widely used frameworks in its category.
Backbone.js has hard dependency on underscore.js and a soft dependency on jQuery. It’s made up of the following modules: