Backbone Tutorials

Getting Started with Backbone.js

When working on a web application that includes a number of JavaScript, one of many first things you study is to cease tying your information to the DOM. It is all too straightforward to create JavaScript functions that find yourself as tangled piles of jQuery selectors and callbacks, all attempting frantically to maintain information in sync between the HTML UI, your JavaScript logic, and the database on your server. For wealthy client-side functions, a extra structured strategy is commonly useful.

With Backbone, you signify your information as Models, which might be created, validated, destroyed, and saved to the server. Every time a UI action causes an attribute of a model to alter, the model triggers a “change” occasion; all of the Views that show the model’s state might be notified of the change, in order that they can reply accordingly, re-rendering themselves with the brand new info. In a completed Backbone app, you do not have to write down the glue code that appears into the DOM to search out a component with a selected id, and replace the HTML manually — when the model modifications, the views merely replace themselves.

Philosophically, Backbone is an try to find the minimal set of data-structuring (models and collections) and person interface (views and URLs) primitives which are typically helpful when constructing web functions with JavaScript. In an ecosystem where overarching, decides-everything-for-you frameworks are commonplace, and plenty of libraries require your web site to be reorganized to swimsuit their look, really feel, and default conduct — Backbone ought to proceed to be a device that provides you the freedom to design the complete expertise of your web application.

When you’re new right here, and are not but fairly certain what Backbone is for, start by looking the list of Backbone-based projects.

Lots of the code examples in this website is executable, as a result of Backbone is included on this web page. Click on the play button to execute them.