an intro to the javascript mvc framework
plan
 Why Backbone
 Backbone architecture
 Examples
What we want to avoid




We have to store object informations into the DOM
What we want to avoid




        callback hell
Why Backbone

So, what do we need?
• Abstraction.
• Decoupling UI from Data.
• No more callbacks.
Backbone.js
From the Backbone website...

               represent datas

Backbone.js gives structure to web applications by providing
models with key-value binding and custom events,
collections with a rich API of enumerable functions,
views with declarative event handling, and connects it all to your
existing API over a RESTful JSON interface.



manipulate doms                           list of model
Architecture
Backboneʼ s Model
Representing data

Handling persistence

Throws events
Backboneʼ s Model
Backboneʼ s Model
Backboneʼ s View

    Manipulates the Dom

    delegates Dom events
Backboneʼ s View
Backboneʼ s View
Backboneʼ s Collections
Collections are ordered sets of models

bind "change" events to be notified when any model
in the collection has been modified


fetch the collection from the server (or other
persistence layer)
Backboneʼ s Collections


                _.include([1, 2, 3], 3);
                => true
APP
Architecture


Dependencies:
• jQuery or Zepto
• Underscore.js 16k

backbone.js 12k
Mustache.js 14k
Examples
Q u e s t io n s ?

Backbone introdunction