官术网_书友最值得收藏!

Basic components of Backbone.js

We will look into some basic concepts of Backbone.js and Underscore.js before moving to the plugin development section. Backbone.js is a client-side MV* framework that provides a set of tools and building blocks required to structure a JavaScript application. Important tools that Backbone.js offers are as follows:

  • Backbone.Model: Models are the entity of an application that store data and contain some logic around data such as validation, conversion, and data interaction.
  • Backbone.View: Views present an idea of organizing your Document Object Model (DOM) interface into logical blocks, and represent the model and collection data in them. Views are excellent tools to organize all the JavaScript event handlers and to add dynamic HTML content in your application via optional use of JavaScript templates. As Backbone follows an MV* pattern, Backbone views mostly work as presenters and take care of the major portion of application functionality.
  • Backbone.Collection: A collection is a group of models. A collection includes a lot of functionality as well as Underscore utility methods to help you work on multiple data models.
  • Backbone.Router: A router provides methods for routing client-side pages and acts subsequently whenever there is a change in the browser's URL. A router maintains the application state as per the URL change.
  • Backbone.Events: Events are an important concept in Backbone, since they provide a mechanism to use the PubSub pattern and decouple your application components.

Apart from these, there are other tools such as Backbone.History, which manages the browser history and the back/forward buttons in accordance with the routers. Also, we have Backbone.Sync, which is a single method that provides a nice abstraction to the network access through Backbone models and collections.

主站蜘蛛池模板: 达孜县| 莆田市| 临沧市| 萍乡市| 荔浦县| 禄丰县| 威信县| 凉城县| 翼城县| 鄱阳县| 溧阳市| 乌兰浩特市| 紫金县| 乌拉特后旗| 甘德县| 白银市| 和政县| 许昌市| 浦江县| 宝鸡市| 临澧县| 涿鹿县| 成都市| 桐乡市| 南部县| 彭泽县| 广汉市| 丁青县| 司法| 柳河县| 凤冈县| 娄烦县| 平江县| 忻城县| 平乐县| 湘乡市| 神农架林区| 前郭尔| 格尔木市| 革吉县| 玉林市|