Backbone Js

Backbone Js

Backbone.js is a model view controller (MVC) Web application framework that provides structure to JavaScript-heavy applications. This is done by supplying models with custom events and key-value binding, views using declarative event handling and collections with a rich application programming interface (API). All of these features are connected to the prevailing application using a RESTful JSON interface.

Backbone can be defined as an exceptionally lightweight library, which allows the creation of easy-to-maintain front ends for applications. It is back-end agnostic and operates very well with existing modern JavaScript libraries. This lightweight library is extremely useful in simplifying the procedure for developing interactive, complex and data-driven applications. Backbone.js offers a neat solution to separate data from presentation by structuring the code and splitting it into semantically meaningful .js files.

The core of Backbone.js includes four major classes:

  • Model: Models are the core part of all JavaScript applications. Models contain interactive data in addition to the substantial element of logic surrounding the data, such as validations, conversions, access control and computed properties. Backbone.Model can be extended with domain-specific methods, and the model offers a standard functionality set to manage the changes. In Backbone.js, the model symbolizes a single entity.
  • Collection: Collections in Backbone.js are basically an array of models. Collections are usually a query result in which the results include a number of models.
  • View: A view in Backbone.js listens to the events thrown by the Document Object Model and collections/models. In addition, it represents the state and data model of the application to the user.
  • Controller: Controllers in Backbone can be used to create stateful, bookmarkable applications with the help of hashbangs.

Example of backbone js