The core in Backbone.js presents the following classes:
- Router — accepts a url and indicates which view you want to run.
- View — there are bound to dom elements, and is responsible for the stored data. The main task is to organize the interface in a logical sequence. This is due to the built-in models.
- Collection — logically are sets of modules. The event, sebatane on the model in the collection, the same will work on the collection. This ensures direct contact with changes the attributes of any model.
- Model — are the most important element of this application. They contain all the interactive data. And validation, conversion, access control and computed properties. Thus, this core set of management changes.
Backbone.js has a list of built-triggered events. These include:
- add — add a model to the collection and the launch event. When the property passed to the raw attributes will change in the model instances. Add the identical model is skipped.
- remove — remove the model from the collection. This event can be suppressed opredelennym the key stored in the hash options.
- reset — replace content in the collection. The updated replacement new array models.
- sort — sort the collection. Typically, the collection is sorted automatically when adding models. If desired, this sorting can be disabled.
- change — change model attribute.
- destroy — destruction model.
- request — send a model request to the server.
- sync — sync the model to the server.
- error — call «save» failed at server.
- invalid — model validation fails.
However, this program not only gives you the opportunity of starting your own.
To perform operations on models of this proxy program six methods. This: pairs, values, keys, pick, invert, omit.