SlideShare a Scribd company logo
Backbone.js
MVC in the Browser




Jonathan Weiss
Who am I?

                            Jonathan Weiss
                             §  Peritor GmbH in Berlin
                             §  Webistrano / Capistrano
                             §  Ruby: SimplyStored, Happening
                             §  FreeBSD: Original Rubygems & Rails maintainer
                             §  The great fire of London




 http://www.peritor.com
 http://github.com/jweiss
 @jweiss



                                                                           2
Scalarium


Amazon EC2 Cluster Management
 §  Auto-Config
 §  Self-Healing
 §  Auto-Scaling
 §  One-click-deployment




www.scalarium.com




                                3
Web App History




                  4
Web 1.0



          GET	


                     Webserver	



           PAGE	





                                    5
Web 1.0
          GET	




           PAGE	

                     Webserver	

          GET	




           PAGE	




                                    6
Ajax



       GET	


                  Webserver	



        PAGE	





                                 7
Ajax
                 GET	




                  PAGE	

                               Webserver	

                 GET	

       PAGE	


                 Fragment	




                                              8
Ajax
                     GET	




                      PAGE	

                                   Logic	

                     GET	

         Load
         PAGE	

       Fragment	

                     Fragment	




                                              9
Ajax
                   GET	




                    PAGE	

       Models,	

                                 Validation,	

                                 Rendering,	

       Mess for    GET	

            ....	

        PAGE	

       complex
         apps	

                   Fragment	




                                                  10
Ajax

       Can get messy really fast

        §  Loading multiple HTML fragments when
            updating single entity


        §  Handle validation errors from the server


        §  Dependency between fragments,
            multiple views need to change on update


        §  TESTING!




                                                       11
12
13
14
15
Principles
             DRY
17
Backbone.js

supplies structure to JavaScript-heavy applications by providing

 §  Models
 §  Collections
 §  Views & Templating
 §  Router




                                                                   18
Backbone.js

http://documentcloud.github.com/backbone/

 §  BSD license
 §  Depends on
    §  jQuery
    §  underscore.js
    §  template engine (build-in, mustache, handlebars, eco, …)
 §  Lightweight – no UI widgets or desktop GUI in the browser
 §  Backend agnostic by talking to RESTful JSON endpoints




                                                                   19
MVC
MVC




Router
Model




 Business model
 Domain logic
 Reusable
Models in Backbone


 Data store
 Setters & setters
 Events & notifications
 Persistence in & out JSON
 (optional)
Collection


 List of models
 Events & notifications
 Adjust with URL / JSON
 List comprehensions:
 map, inject, select, …
View




 Presentation
 Specific to a use-case
 Different views for
 different perspectives on a
 model
Views in Backbone




 Display UI & data
 Templating
 Respond to user input
 Respond to model change
Controller




 Conducts and connects
 Inspects user requests and
 responds
 Delegate instead of work
Router in Backbone




 Map URLs to JS actions
 History state management
 Instantiation of initial setup
Workflow with Backbone.js



                 fetch	



    Model	

                Server	

                JSON	





                                        29
Workflow with Backbone.js

 View 1	

          View 2	



        notify	



                         fetch	



    Model	

                        Server	

                        JSON	

                                                30
Workflow with Backbone.js
                                    render	

 View 1	

          View 2	



        notify	



                         fetch	



    Model	

                            Server	

                        JSON	

                                                    31
Workflow with Backbone.js
                                          render	

 View 1	

          View 2	

                                           update	


                                    inject	

        notify	



                         fetch	



    Model	

                                    Server	

                        JSON	

                                                            32
Workflow with Backbone.js

 View 1	

     View 2	

                           update, click, input,...	





    Model
Workflow with Backbone.js

 View 1	

          View 2	

                                update, click, input,...	




               update	





    Model
Workflow with Backbone.js

 View 1	

               View 2	

                                     update, click, input,...	




                    update	

  notify	





         Model
Workflow with Backbone.js

 View 1	

               View 2	

                                            update, click, input,...	




                    update	

  notify	




                                update	

         Model	

                                       Server	

                                JSON	


                                                                          36
Workflow with Backbone.js
                                      render	

 View 1	

          View 2	

                                       update	


                                inject	

        notify	





    Model	


                                                   37
Show Me The Code




                   38
Model




        39
Collection




Assumes RESTful JSON backed, e.g. /servers/4646 …




                                                    40
View




       41
View




       42
View




       43
Custom Events




                44
Custom Events




                45
46
Data, Events & Views

Pattern

 §  User or server trigger data change, never update view directly
 §  Data update triggers change event
 §  Views subscribe to change events and re-render


 §  Router to connect URLs to actions and initialize views




                                                                      47
Give Me More




               48
Validations




Failed validation will prevent set and save
Triggers error event

                                              49
List Comprehensions




                      50
List Comprehensions




Short form for map on an attribute



                                     51
Navigation & Back Button




                           52
53
54
55
http://documentcloud.github.com/backbone/




http://peepcode.com/products/backbone-js   http://peepcode.com/products/backbone-ii



                                                                                      56
Q&A
Peritor GmbH
Blücherstr. 22, Hof III Aufgang 6
10961 Berlin
Tel.: +49 (0)30 69 20 09 84 0
Fax: +49 (0)30 69 20 09 84 9
Internet: www.peritor.com
E-Mail: info@peritor.com



© Peritor GmbH - Alle Rechte vorbehalten

More Related Content

PDF
Build your own clouds with Chef and MCollective
PDF
Scalarium and CouchDB
PDF
Docker on AWS OpsWorks
PDF
Amazon SWF and Gordon
PDF
Running your Java EE 6 applications in the Cloud (FISL 12)
PDF
ChefConf 2014 - AWS OpsWorks Under The Hood
PPTX
Deploying your web application with AWS ElasticBeanstalk
PDF
docker-machine, docker-compose, docker-swarm 覚書
Build your own clouds with Chef and MCollective
Scalarium and CouchDB
Docker on AWS OpsWorks
Amazon SWF and Gordon
Running your Java EE 6 applications in the Cloud (FISL 12)
ChefConf 2014 - AWS OpsWorks Under The Hood
Deploying your web application with AWS ElasticBeanstalk
docker-machine, docker-compose, docker-swarm 覚書

What's hot (6)

PPTX
DevOps with Elastic Beanstalk - TCCC-2014
PDF
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
PDF
Ansible Introduction
PDF
Installing WordPress on AWS
PPTX
Automating Azure VMs with PowerShell
PDF
Infrastructure as Code for Beginners
DevOps with Elastic Beanstalk - TCCC-2014
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
Ansible Introduction
Installing WordPress on AWS
Automating Azure VMs with PowerShell
Infrastructure as Code for Beginners
Ad

Viewers also liked (20)

PDF
Introduction à Marionette
PPT
Backbone.js
PDF
AngularJS vs. Ember.js vs. Backbone.js
PPTX
Backbone And Marionette : Take Over The World
PDF
Intro to Backbone.js by Azat Mardanov for General Assembly
PDF
Introduction to Backbone.js
KEY
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
PPTX
MVC & backbone.js
PPTX
Backbone/Marionette recap [2015]
PDF
Introduction to Marionette Collective
PPTX
Introduction to Backbone.js & Marionette.js
PPTX
Marionette talk 2016
PDF
Client-side MVC with Backbone.js
PDF
introduction to Marionette.js (jscafe14)
PPTX
Backbone.js
PDF
Marionette: the Backbone framework
PDF
PPTX
Introduction to Backbone.js
PPSX
RequireJS
PDF
Module, AMD, RequireJS
Introduction à Marionette
Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
Backbone And Marionette : Take Over The World
Intro to Backbone.js by Azat Mardanov for General Assembly
Introduction to Backbone.js
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
MVC & backbone.js
Backbone/Marionette recap [2015]
Introduction to Marionette Collective
Introduction to Backbone.js & Marionette.js
Marionette talk 2016
Client-side MVC with Backbone.js
introduction to Marionette.js (jscafe14)
Backbone.js
Marionette: the Backbone framework
Introduction to Backbone.js
RequireJS
Module, AMD, RequireJS
Ad

Similar to Introduction to Backbone.js (20)

PPTX
Planbox Backbone MVC
PDF
Viking academy backbone.js
PPTX
Single Page Application Development with backbone.js and Simple.Web
PDF
Backbone.js
PDF
Javascript MVC & Backbone Tips & Tricks
PDF
Javascript Application Architecture with Backbone.JS
PPT
Vanjs backbone-powerpoint
PPTX
Building SPA’s (Single Page App) with Backbone.js
PPTX
Show Some Spine!
PPTX
Creating Single Page Web App using Backbone JS
PDF
An approach to responsive, realtime with Backbone.js and WebSockets
KEY
Backbonification for dummies - Arrrrug 10/1/2012
ODP
Javascript frameworks: Backbone.js
PDF
Backbone.js slides
PPTX
Building single page applications
PPTX
Writing HTML5 Web Apps using Backbone.js and GAE
PPTX
Backbone the Good Parts
PPTX
Javascript for Wep Apps
PPTX
Give your web apps some backbone
KEY
Single Page Web Apps with Backbone.js and Rails
Planbox Backbone MVC
Viking academy backbone.js
Single Page Application Development with backbone.js and Simple.Web
Backbone.js
Javascript MVC & Backbone Tips & Tricks
Javascript Application Architecture with Backbone.JS
Vanjs backbone-powerpoint
Building SPA’s (Single Page App) with Backbone.js
Show Some Spine!
Creating Single Page Web App using Backbone JS
An approach to responsive, realtime with Backbone.js and WebSockets
Backbonification for dummies - Arrrrug 10/1/2012
Javascript frameworks: Backbone.js
Backbone.js slides
Building single page applications
Writing HTML5 Web Apps using Backbone.js and GAE
Backbone the Good Parts
Javascript for Wep Apps
Give your web apps some backbone
Single Page Web Apps with Backbone.js and Rails

More from Jonathan Weiss (20)

PDF
AWS OpsWorks & Chef at the Hamburg Chef User Group 2014
PPTX
DevOpsDays Amsterdam - Observations in the cloud
PDF
NoSQL - Motivation and Overview
PDF
NoSQL - An introduction to CouchDB
PDF
Running on Amazon EC2
PDF
Amazon EC2 in der Praxis
PDF
Infrastructure Automation with Chef
PDF
Rails in the Cloud
PDF
EventMachine
PDF
CouchDB on Rails
PDF
Rails in the Cloud - Experiences from running on EC2
PDF
CouchDB on Rails - RailsWayCon 2010
PDF
CouchDB on Rails - FrozenRails 2010
PDF
NoSQL - Post-Relational Databases - BarCamp Ruhr3
PDF
Ruby on CouchDB - SimplyStored and RockingChair
PDF
No SQL - BarCamp Nürnberg 2010
PPTX
BarCamp Nürnberg - Infrastructure As A Service
PDF
Rails Security
PPT
Scaling Rails
PPT
Refactoring Rails Applications
AWS OpsWorks & Chef at the Hamburg Chef User Group 2014
DevOpsDays Amsterdam - Observations in the cloud
NoSQL - Motivation and Overview
NoSQL - An introduction to CouchDB
Running on Amazon EC2
Amazon EC2 in der Praxis
Infrastructure Automation with Chef
Rails in the Cloud
EventMachine
CouchDB on Rails
Rails in the Cloud - Experiences from running on EC2
CouchDB on Rails - RailsWayCon 2010
CouchDB on Rails - FrozenRails 2010
NoSQL - Post-Relational Databases - BarCamp Ruhr3
Ruby on CouchDB - SimplyStored and RockingChair
No SQL - BarCamp Nürnberg 2010
BarCamp Nürnberg - Infrastructure As A Service
Rails Security
Scaling Rails
Refactoring Rails Applications

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Modernizing your data center with Dell and AMD
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MYSQL Presentation for SQL database connectivity
Modernizing your data center with Dell and AMD
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Monthly Chronicles - July 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Unlocking AI with Model Context Protocol (MCP)

Introduction to Backbone.js