28. Downloads & Dependencies
Development Version (0.5.1) 41kb, Full Source with Comments
Production Version (0.5.1) 4.6kb, Packed and Gzipped
Backbone's only hard dependency is Underscore.js.
For RESTful persistence, history support via Backbone.ControllerRouter and
DOM manipulation with Backbone.View, include json2.js, and either jQuery
( > 1.4.2) or Zepto.
48. Backbone.View
• A logical UI component, not just the
template
• They are more like Rail’s Controller
• Responsible for instantiating
Collections and binding events that
update the UI
56. Backbone.Events
◦ "add" (model, collection) — when a model is added to a collection.
◦ "remove" (model, collection) — when a model is removed from a collection.
◦ "reset" (collection) — when the collection's entire contents have been replaced.
◦ "change" (model, collection) — when a model's attributes have changed.
◦ "change:[attribute]" (model, collection) — when a specific attribute has been updated.
◦ "destroy" (model, collection) — when a model is destroyed.
◦ "error" (model, collection) — when a model's validation fails, or a save call fails on the server.
◦ "route:[name]" (router) — when one of a router's routes has matched.
◦ "all" — this special event fires for any triggered event, passing the event name as the first
argument.
58. Backbone.Sync
Backbone.sync is the function that Backbone calls every time it
attempts to read or save a model to the server. By default, it uses
(jQuery/Zepto).ajax to make a RESTful JSON request. You can
override it in order to use a different persistence strategy, such as
WebSockets, XML transport, or Local Storage.
61. Models Collections
Interactive Data Domain-
Ordered Sets of Models
specific methods
62. Models Collections
Interactive Data Domain-
Ordered Sets of Models
specific methods
Views
Render HTML/CSS With
Javascript templating
63. Models Collections
Interactive Data Domain-
Ordered Sets of Models
specific methods
Views Router
Render HTML/CSS With Methods For Routing URL
Javascript templating Fragments
64. Models Collections
Interactive Data Domain-
Ordered Sets of Models
specific methods
Views Router
Render HTML/CSS With Methods For Routing URL
Javascript templating Fragments
65. Models Collections
Interactive Data Domain-
Ordered Sets of Models
specific methods
Views Router
Render HTML/CSS With Methods For Routing URL
Javascript templating Fragments
90. new App.Views.StreamItem();
model: Status
Status model.fetch()
this.render()
Resharers new App.Views.Resharers()...
Comments
91. new App.Views.StreamItem();
model: Status
Status model.fetch()
this.render()
Resharers new App.Views.Resharers()...
new App.Views.Comments()
this.collection = new Comments({
id: status.id
Com