SlideShare a Scribd company logo
Gran Sasso Science Institute
Ivano Malavolta
Backbone JS
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Why Backbone
We are buildingapps, not web sites
If your code is not structured:
• it is extremely easy that your web app becomes a
big mess of HTML + CSS + JavaScript
• maintainingeach part of your app asks for a
deep analysis of ALL its aspects (logic, presentation, etc.)
• you may waste a whole day due to a missing <
Why Backbone
Backbone gives you STRUCTURE
What we want to avoid
Imagine yourself trying to change
• how a movie should be rendered in your app
• the REST API providing info about movies
Why Backbone (1)
From the Backbone website...
manipulate
the DOM
lists
of models
represent
data
Why Backbone (2)
Additionally,Backbone provides also features for:
sync
for managing how to persist models (default is via REST)
events
for managing how data and control are exchanged within your app
router
for managing the interaction flow among views
Backbone in a nutshell
Who is using Backbone?
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Events
Any object communicates with other objects via events
It gives the object the ability to bind and trigger custom named events
It is extremely useful for exchanging data and control among objects
Events
Basically, each object can:
• listen to events
• trigger events
Events
Two types of events:
you define your own types of event
built-in
custom
Events API
object will react to the “alert” event
(the “off” function detaches the event)
event parameters
the “alert” event is
fired
Events API
Events methods:
on
object.on(event, callback, [context])
off
object.off([event], [callback], [context])
once
object.once(event, callback, [context])
trigger
object.trigger(event, [*args])
listenTo
object.listenTo(other, event, callback)
stopListening
object.stopListening([other], [event], [callback])
listenToOnce
object.listenToOnce(other, event, callback)
Events summary
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Models
Models represent your data
Each model represents a data type in your app, together with the logic surroundingit, like:
• persistence
• conversions
• validation
• computed properties
• access control
MVC: Notify their observers about
state using the Observer pattern
Models
You extend Backbone.Model with your domain-specific methods, and Model provides a basic set of
functionalityfor managing changes, like:
• getter and setter
• id
• constructor
• REST-based persistence
Example of model
custom method
setting an
attribute
event fired when
“color” changes
custom method
invocation
Model constructor and attributes
initialize()
it is triggered every time you create a new instance of a model
it works also for collections and views
it can take a JS object for setting also attributes
get() & set()
they are used to set and retrieve the value of certain attributes
defaults
a property named 'defaults' in your model declaration
Example
http://goo.gl/UOahsP
Model persistence
Backbone.sync
is the function that Backbone calls every time it attempts to read or save a model
By default, it uses Ajax to make a REST-ish request to a server
Resources represented
as JSON strings
Sync signature
sync(method, model, [options])
method
the CRUD method ("create“, "read“, "update", or "delete")
model
the model (or collection)to be synced
options
success and error callbacks, and all other jQuery request options
example of overriden sync:
http://bit.ly/KWdxNN
Sync returns a jQuery XMLHttpRequest (jqXHR) object
It implements the Promise
interface
Sync usage
Normally you will not use the sync method directly, you will do it implicitlywhen you call one of these
methods
Model
• fetch: gets the most up-to-date values of the model instance
• save: persists the model instance
• destroy: deletes the model instance
Collection
• fetch: gets all the models of the collection from the server
• create: creates a model, saves it to the server and adds it to the collection
Overriding sync
You can override it in order to use a different persistence strategy, such as:
• WebSockets
• Local Storage
• WebSQL
Backbone.sync is the default global function that all models use unless the models have a sync method
specifically set
Models summary
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Collections
Collections are ordered sets of models
You can:
• bind change events to be notified when any model in the collection has been modified
• listen for add and remove events
• fetch the collection from the server (or other persistence layers)
• find models or filter collections themeselves
The model attribute of a collection represents the kind of model that can be stored in it
Any event that is triggered on a model in a collection
will also be triggered on the collection directly
MVC: Notify their observers
about state using the Observer
pattern (same as models)
Collection example
http://goo.gl/UOahsP
Collections summary
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Views
Views represent and manage the visible parts of your application
They are also used to
• listen to user interaction events
• and react accordingly
views can be rendered at any time, and inserted into the DOM
you get high-performance UI rendering
with as few reflows and repaints as possible
MVC: a view observes a model, and
updates itself according to the state
of the model + manage user inputs
(it’s a controller, to this sense)
Interaction with the DOM
All views refer to a DOM element at all times
this.el is a reference to the DOM element, it is created from:
tagName
for example body, ul, span, img
className
class name of some element within the DOM
id
id of an element within the DOM
If none of them is specified,
this.el is an empty <div>
Rendering the view
The render() method is used to update the this.el element with the new HTML
The default implementation of render() is a no-op
à you have to override it to update this.el with your HTML code
Backbone is agnostic with respect to your code in render(), however...
you are STRONGLY encouraged to use a
JavaScript templating library here
View example
http://goo.gl/UOahsP
Interaction with the user
Events map
“event_name selector”: callback
Events callbacks
Views summary
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
The router
Backbone.Router provides methods for routingclient-side pages,
and connecting them to actions and events
At a minimum, a router is composed of two main parts:
routes
an hash that pairs routes to actions
actions
JS functionstriggered when certain routes are navigated
It can be seen as the “implementation”
of a navigation model
Routing
Every router contains an hash that maps routes to functions on your router
URLs fragments can also contain dynamic data via Backbone-specific URL parts:
parameter (:param)
match a single URL component between slashes
splat (*fragment)
match any number of URL components
Routing
routes map
routing
functions
History
History serves as a global router to
1. handle hashchange events
2. match the appropriate route
3. trigger callbacks
You should never access it directly, you just need call Backbone.history.start() to begin
monitoringhashchange events, and dispatching routes in your app
Call Backbone.history.navigate(ROUTE_NAME, {trigger: true}); to activate a specific route
of the router
Technically, it uses the HTML5
History API to listen to its job
For older browsers, it uses URL hash
fragments as fallback
Router summary
Roadmap
• Why Backbone
• Events
• Models
• Collections
• Views
• Routers
• Summary
Classical workflow
1. You dig into JSON objects
2. Look up elements in the DOM
3. Update the HTML by hand
Backbone-based workflow
• You organize your interface into logical views backed by models
• Each view can be updated independently when the model changes,
without having to redraw the page
You can bind your view‘s
render() function to the
model‘s "change” event
à now everywhere that
model data is displayed in the
UI, it is always immediately up
to date
Is Backbone real MVC?
Let’s look at the description of the Model-View-Presenter pattern on Wikipedia:
an interface definingthe data to be displayed or otherwise acted upon in the user interface
passive interface that displays data (the model) and routes user commands (events) to the
presenter to act upon that data
acts upon the model and the view. It retrieves data from repositories (the model), and formats it
for display in the view
Model
View
Presenter
LAB
1. Organize the software architecture of the app using Backbone’s MVC paradigm
2. implement the Product, Producer, and User models
3. implement the Products and Producers collections
• if needed, override the sync method so that it can fetch data from the Loveitaly API
4. implement the views
5. implement the router of the app
References
http://backbonejs.org
Contact
Ivano Malavolta |
Gran Sasso Science Institute
iivanoo
ivano.malavolta@gssi.infn.it
www.ivanomalavolta.com

More Related Content

What's hot

Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Doris Chen
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 RefresherIvano Malavolta
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPMohammad Shaker
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVAYash Mody
 
Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Henry Van Styn
 
1. Spring intro IoC
1. Spring intro IoC1. Spring intro IoC
1. Spring intro IoCASG
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsFabio Franzini
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014Henry Van Styn
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applicationsIvano Malavolta
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationWebStackAcademy
 

What's hot (20)

Rest
Rest Rest
Rest
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
jQuery
jQueryjQuery
jQuery
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
 
Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017
 
1. Spring intro IoC
1. Spring intro IoC1. Spring intro IoC
1. Spring intro IoC
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014
 
Aem best practices
Aem best practicesAem best practices
Aem best practices
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Mvc4
Mvc4Mvc4
Mvc4
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
 

Viewers also liked

[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural styleIvano Malavolta
 
[2015/2016] Mobile thinking
[2015/2016] Mobile thinking[2015/2016] Mobile thinking
[2015/2016] Mobile thinkingIvano Malavolta
 
[2015/2016] Apache Cordova APIs
[2015/2016] Apache Cordova APIs[2015/2016] Apache Cordova APIs
[2015/2016] Apache Cordova APIsIvano Malavolta
 
[2015/2016] User-centred design
[2015/2016] User-centred design[2015/2016] User-centred design
[2015/2016] User-centred designIvano Malavolta
 
[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mappingIvano Malavolta
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache CordovaIvano Malavolta
 
The road ahead for architectural languages [ACVI 2016]
The road ahead for architectural languages [ACVI 2016]The road ahead for architectural languages [ACVI 2016]
The road ahead for architectural languages [ACVI 2016]Ivano Malavolta
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile appsIvano Malavolta
 
[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigmsIvano Malavolta
 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architectureIvano Malavolta
 
[2015/2016] AADL (Architecture Analysis and Design Language)
[2015/2016] AADL (Architecture Analysis and Design Language)[2015/2016] AADL (Architecture Analysis and Design Language)
[2015/2016] AADL (Architecture Analysis and Design Language)Ivano Malavolta
 
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...Ivano Malavolta
 
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...Ivano Malavolta
 
[2015/2016] User experience design of mobil apps
[2015/2016] User experience design of mobil apps[2015/2016] User experience design of mobil apps
[2015/2016] User experience design of mobil appsIvano Malavolta
 
Design patterns for mobile apps
Design patterns for mobile appsDesign patterns for mobile apps
Design patterns for mobile appsIvano Malavolta
 
Mission planning of autonomous quadrotors
Mission planning of autonomous quadrotorsMission planning of autonomous quadrotors
Mission planning of autonomous quadrotorsIvano Malavolta
 
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
Beyond Native Apps:  Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...Beyond Native Apps:  Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...Ivano Malavolta
 
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...Ivano Malavolta
 
SKA Systems Engineering: from PDR to Construction
SKA Systems Engineering: from PDR to ConstructionSKA Systems Engineering: from PDR to Construction
SKA Systems Engineering: from PDR to ConstructionJoint ALMA Observatory
 
[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLESIvano Malavolta
 

Viewers also liked (20)

[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural style
 
[2015/2016] Mobile thinking
[2015/2016] Mobile thinking[2015/2016] Mobile thinking
[2015/2016] Mobile thinking
 
[2015/2016] Apache Cordova APIs
[2015/2016] Apache Cordova APIs[2015/2016] Apache Cordova APIs
[2015/2016] Apache Cordova APIs
 
[2015/2016] User-centred design
[2015/2016] User-centred design[2015/2016] User-centred design
[2015/2016] User-centred design
 
[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
 
The road ahead for architectural languages [ACVI 2016]
The road ahead for architectural languages [ACVI 2016]The road ahead for architectural languages [ACVI 2016]
The road ahead for architectural languages [ACVI 2016]
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
 
[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms
 
[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture[2015/2016] Introduction to software architecture
[2015/2016] Introduction to software architecture
 
[2015/2016] AADL (Architecture Analysis and Design Language)
[2015/2016] AADL (Architecture Analysis and Design Language)[2015/2016] AADL (Architecture Analysis and Design Language)
[2015/2016] AADL (Architecture Analysis and Design Language)
 
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
 
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
 
[2015/2016] User experience design of mobil apps
[2015/2016] User experience design of mobil apps[2015/2016] User experience design of mobil apps
[2015/2016] User experience design of mobil apps
 
Design patterns for mobile apps
Design patterns for mobile appsDesign patterns for mobile apps
Design patterns for mobile apps
 
Mission planning of autonomous quadrotors
Mission planning of autonomous quadrotorsMission planning of autonomous quadrotors
Mission planning of autonomous quadrotors
 
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
Beyond Native Apps:  Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...Beyond Native Apps:  Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
 
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
 
SKA Systems Engineering: from PDR to Construction
SKA Systems Engineering: from PDR to ConstructionSKA Systems Engineering: from PDR to Construction
SKA Systems Engineering: from PDR to Construction
 
[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES
 

Similar to [2015/2016] Backbone JS

Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile appsIvano Malavolta
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!Roberto Messora
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Dimitri de Putte
 
Backbonejs
BackbonejsBackbonejs
BackbonejsSam Lee
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutAndoni Arroyo
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsJennifer Estrada
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Raybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript LibraryRaybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript Libraryray biztech
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.jsBert Wijnants
 

Similar to [2015/2016] Backbone JS (20)

Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
MVC
MVCMVC
MVC
 
Show Some Spine!
Show Some Spine!Show Some Spine!
Show Some Spine!
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAs
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Raybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript LibraryRaybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript Library
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 

More from Ivano Malavolta

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Ivano Malavolta
 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)Ivano Malavolta
 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green ITIvano Malavolta
 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Ivano Malavolta
 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]Ivano Malavolta
 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Ivano Malavolta
 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Ivano Malavolta
 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Ivano Malavolta
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Ivano Malavolta
 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Ivano Malavolta
 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Ivano Malavolta
 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Ivano Malavolta
 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Ivano Malavolta
 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile developmentIvano Malavolta
 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architecturesIvano Malavolta
 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design LanguageIvano Malavolta
 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languagesIvano Malavolta
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software ArchitectureIvano Malavolta
 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineeringIvano Malavolta
 

More from Ivano Malavolta (20)

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
 
The H2020 experience
The H2020 experienceThe H2020 experience
The H2020 experience
 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green IT
 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...
 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...
 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile development
 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architectures
 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language
 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languages
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture
 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

[2015/2016] Backbone JS

  • 1. Gran Sasso Science Institute Ivano Malavolta Backbone JS
  • 2. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 3. Why Backbone We are buildingapps, not web sites If your code is not structured: • it is extremely easy that your web app becomes a big mess of HTML + CSS + JavaScript • maintainingeach part of your app asks for a deep analysis of ALL its aspects (logic, presentation, etc.) • you may waste a whole day due to a missing <
  • 5. What we want to avoid Imagine yourself trying to change • how a movie should be rendered in your app • the REST API providing info about movies
  • 6. Why Backbone (1) From the Backbone website... manipulate the DOM lists of models represent data
  • 7. Why Backbone (2) Additionally,Backbone provides also features for: sync for managing how to persist models (default is via REST) events for managing how data and control are exchanged within your app router for managing the interaction flow among views
  • 8. Backbone in a nutshell
  • 9. Who is using Backbone?
  • 10. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 11. Events Any object communicates with other objects via events It gives the object the ability to bind and trigger custom named events It is extremely useful for exchanging data and control among objects
  • 12. Events Basically, each object can: • listen to events • trigger events
  • 13. Events Two types of events: you define your own types of event built-in custom
  • 14. Events API object will react to the “alert” event (the “off” function detaches the event) event parameters the “alert” event is fired
  • 15. Events API Events methods: on object.on(event, callback, [context]) off object.off([event], [callback], [context]) once object.once(event, callback, [context]) trigger object.trigger(event, [*args]) listenTo object.listenTo(other, event, callback) stopListening object.stopListening([other], [event], [callback]) listenToOnce object.listenToOnce(other, event, callback)
  • 17. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 18. Models Models represent your data Each model represents a data type in your app, together with the logic surroundingit, like: • persistence • conversions • validation • computed properties • access control MVC: Notify their observers about state using the Observer pattern
  • 19. Models You extend Backbone.Model with your domain-specific methods, and Model provides a basic set of functionalityfor managing changes, like: • getter and setter • id • constructor • REST-based persistence
  • 20. Example of model custom method setting an attribute event fired when “color” changes custom method invocation
  • 21. Model constructor and attributes initialize() it is triggered every time you create a new instance of a model it works also for collections and views it can take a JS object for setting also attributes get() & set() they are used to set and retrieve the value of certain attributes defaults a property named 'defaults' in your model declaration
  • 23. Model persistence Backbone.sync is the function that Backbone calls every time it attempts to read or save a model By default, it uses Ajax to make a REST-ish request to a server Resources represented as JSON strings
  • 24. Sync signature sync(method, model, [options]) method the CRUD method ("create“, "read“, "update", or "delete") model the model (or collection)to be synced options success and error callbacks, and all other jQuery request options example of overriden sync: http://bit.ly/KWdxNN Sync returns a jQuery XMLHttpRequest (jqXHR) object It implements the Promise interface
  • 25. Sync usage Normally you will not use the sync method directly, you will do it implicitlywhen you call one of these methods Model • fetch: gets the most up-to-date values of the model instance • save: persists the model instance • destroy: deletes the model instance Collection • fetch: gets all the models of the collection from the server • create: creates a model, saves it to the server and adds it to the collection
  • 26. Overriding sync You can override it in order to use a different persistence strategy, such as: • WebSockets • Local Storage • WebSQL Backbone.sync is the default global function that all models use unless the models have a sync method specifically set
  • 28. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 29. Collections Collections are ordered sets of models You can: • bind change events to be notified when any model in the collection has been modified • listen for add and remove events • fetch the collection from the server (or other persistence layers) • find models or filter collections themeselves The model attribute of a collection represents the kind of model that can be stored in it Any event that is triggered on a model in a collection will also be triggered on the collection directly MVC: Notify their observers about state using the Observer pattern (same as models)
  • 32. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 33. Views Views represent and manage the visible parts of your application They are also used to • listen to user interaction events • and react accordingly views can be rendered at any time, and inserted into the DOM you get high-performance UI rendering with as few reflows and repaints as possible MVC: a view observes a model, and updates itself according to the state of the model + manage user inputs (it’s a controller, to this sense)
  • 34. Interaction with the DOM All views refer to a DOM element at all times this.el is a reference to the DOM element, it is created from: tagName for example body, ul, span, img className class name of some element within the DOM id id of an element within the DOM If none of them is specified, this.el is an empty <div>
  • 35. Rendering the view The render() method is used to update the this.el element with the new HTML The default implementation of render() is a no-op à you have to override it to update this.el with your HTML code Backbone is agnostic with respect to your code in render(), however... you are STRONGLY encouraged to use a JavaScript templating library here
  • 37. Interaction with the user Events map “event_name selector”: callback Events callbacks
  • 39. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 40. The router Backbone.Router provides methods for routingclient-side pages, and connecting them to actions and events At a minimum, a router is composed of two main parts: routes an hash that pairs routes to actions actions JS functionstriggered when certain routes are navigated It can be seen as the “implementation” of a navigation model
  • 41. Routing Every router contains an hash that maps routes to functions on your router URLs fragments can also contain dynamic data via Backbone-specific URL parts: parameter (:param) match a single URL component between slashes splat (*fragment) match any number of URL components
  • 43. History History serves as a global router to 1. handle hashchange events 2. match the appropriate route 3. trigger callbacks You should never access it directly, you just need call Backbone.history.start() to begin monitoringhashchange events, and dispatching routes in your app Call Backbone.history.navigate(ROUTE_NAME, {trigger: true}); to activate a specific route of the router Technically, it uses the HTML5 History API to listen to its job For older browsers, it uses URL hash fragments as fallback
  • 45. Roadmap • Why Backbone • Events • Models • Collections • Views • Routers • Summary
  • 46. Classical workflow 1. You dig into JSON objects 2. Look up elements in the DOM 3. Update the HTML by hand
  • 47. Backbone-based workflow • You organize your interface into logical views backed by models • Each view can be updated independently when the model changes, without having to redraw the page You can bind your view‘s render() function to the model‘s "change” event à now everywhere that model data is displayed in the UI, it is always immediately up to date
  • 48. Is Backbone real MVC? Let’s look at the description of the Model-View-Presenter pattern on Wikipedia: an interface definingthe data to be displayed or otherwise acted upon in the user interface passive interface that displays data (the model) and routes user commands (events) to the presenter to act upon that data acts upon the model and the view. It retrieves data from repositories (the model), and formats it for display in the view Model View Presenter
  • 49. LAB 1. Organize the software architecture of the app using Backbone’s MVC paradigm 2. implement the Product, Producer, and User models 3. implement the Products and Producers collections • if needed, override the sync method so that it can fetch data from the Loveitaly API 4. implement the views 5. implement the router of the app
  • 51. Contact Ivano Malavolta | Gran Sasso Science Institute iivanoo ivano.malavolta@gssi.infn.it www.ivanomalavolta.com