SlideShare uma empresa Scribd logo
1 de 13
Introduction à
Backbone.JS
@sylzys sylzys
Sylvain Zyssman
29/05/2013
mardi 21 mai 13
Backbone,  c’est  quoi  ?
• Framework Javascript:
M (Modèle)
V (Vue)
C (Collection)
+ Router
• Une seule dépendance ferme (Underscore.js)
• Compatible avec plusieurs moteurs de template
mardi 21 mai 13
Backbone,  pourquoi  ?
• Principalement pour les Single Page Application
• Navigation, formulaires ... gèrés en javascript
• Evénements sur des changements de valeurs de
nos modèles => rafraichissement
automatiquement des vues
•Possède son propre routeur
mardi 21 mai 13
Comment  ?
Un modèle simple
var Todo = Backbone.Model.extend({
defaults: {
title:"backbone",
language:"javascript"
},
initialize: function(){
console.log('model initialized');
this.on('change:title', function(){
console.log("model title has changed");
});
}
});
var my_todo = new Todo();
var my_todo_with_param({title : «Angular»});
my_todo.get(‘title’);
my_todo_with_param.set({language : «JS»});
mardi 21 mai 13
Backbone Methods
extend
constructor / initialize
get
set
escape
has
unset
clear
id
idAttribute
cid
attributes
changed
defaults
toJSON
sync
fetch
save
destroy
Underscore Methods
validate
validationError
isValid
url
urlRoot
parse
clone
isNew
hasChanged
changedAttributes
previous
previousAttributes
mardi 21 mai 13
Comment  ?
Une vue simple
var ListView = Backbone.View.extend({
el: $('body'),
initialize: function(){
_.bindAll(this, 'render');
this.render();
},
render: function(){
$(this.el).append("<ul> <li>hello world</li> </
ul>");
}
});
var listView = new ListView();
mardi 21 mai 13
Backbone Methods
extend
constructor / initialize
el
$el
setElement
attributes
$ (jQuery)
render
remove
delegateEvents
undelegateEvents
mardi 21 mai 13
Comment  ?
Une collection simple
var List = Backbone.Collection.extend({
model: Todo
});
On apporte les modifications à la vue :
• Déclaration dans la fonction «initialize»
this.collection = new List();
this.collection.bind('add',
this.appendItem);
• Liaison de la collection et de la vue
_(this.collection.models).each(function(item){
self.appendItem(item);
}, this);
mardi 21 mai 13
Backbone Methods
extend
model
constructor / initialize
models
toJSON
sync
Underscore Methods
add
remove
reset
set
get
at
push
pop
unshift
shift
slice
length
comparator
sort
pluck
where
findWhere
url
parse
clone
fetch
create
mardi 21 mai 13
Backbone.JS
La démo
mardi 21 mai 13
Backbone,  et  après  ?
Construits sur Backbone.js
• Chaplin.js
• Marionette.js
D’autres frameworks Javascript
• Angular.js
• Ember.js
• Batman.js
• Knockout.js
• ...
mardi 21 mai 13
Backbone,  des  liens  u9les
•http://backbonejs.org/
•http://documentcloud.github.io/backbone/docs/backbone.html
•http://bardevblog.wordpress.com/2012/12/04/re-learning-backbone-
js/
•http://fr.clever-age.com/veille/blog/decouvrir-backbone-js-avec-
todomvc.html
•http://addyosmani.github.io/backbone-fundamentals/
mardi 21 mai 13
Backbone.JS
Des questions ?
mardi 21 mai 13

Mais conteúdo relacionado

Destaque

Анализ украинских олимпиад по информатике 2015
Анализ украинских олимпиад по информатике 2015Анализ украинских олимпиад по информатике 2015
Анализ украинских олимпиад по информатике 2015Michael Rybak
 
Ch123pr ketut-101105084210-phpapp01
Ch123pr ketut-101105084210-phpapp01Ch123pr ketut-101105084210-phpapp01
Ch123pr ketut-101105084210-phpapp01tommathew16
 
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)Yu-Chia Hsu
 
Good or Evil: les fonctions anonymes en Javascript
Good or Evil: les fonctions anonymes en JavascriptGood or Evil: les fonctions anonymes en Javascript
Good or Evil: les fonctions anonymes en JavascriptNoirdes
 
аллея доблести и славы редуктор
аллея доблести и славы редуктораллея доблести и славы редуктор
аллея доблести и славы редукторSay2rus
 
Посібник для новобранців
Посібник для новобранцівПосібник для новобранців
Посібник для новобранцівЮрій Марченко
 
CE Partners meeting Nrb enos_Swahili version
CE Partners meeting Nrb enos_Swahili versionCE Partners meeting Nrb enos_Swahili version
CE Partners meeting Nrb enos_Swahili versionEnos Omondi
 
Invitacion de cumpleaños
Invitacion de cumpleañosInvitacion de cumpleaños
Invitacion de cumpleañosRosy Arias
 
Pdhpe rationale
Pdhpe rationalePdhpe rationale
Pdhpe rationaleOHARA295
 

Destaque (20)

Business Incentives | DSLBD | Doing Business 2.0
Business Incentives | DSLBD | Doing Business 2.0Business Incentives | DSLBD | Doing Business 2.0
Business Incentives | DSLBD | Doing Business 2.0
 
Alternative Sources of Funding | Charlie Kiser
Alternative Sources of Funding | Charlie KiserAlternative Sources of Funding | Charlie Kiser
Alternative Sources of Funding | Charlie Kiser
 
Анализ украинских олимпиад по информатике 2015
Анализ украинских олимпиад по информатике 2015Анализ украинских олимпиад по информатике 2015
Анализ украинских олимпиад по информатике 2015
 
Business Taxes | Venable | Doing Business 2.0
Business Taxes | Venable | Doing Business 2.0Business Taxes | Venable | Doing Business 2.0
Business Taxes | Venable | Doing Business 2.0
 
Ch123pr ketut-101105084210-phpapp01
Ch123pr ketut-101105084210-phpapp01Ch123pr ketut-101105084210-phpapp01
Ch123pr ketut-101105084210-phpapp01
 
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)
The world's 10 great societies 世界十大偉大社會 (非清晰版)(開音箱)
 
VerdeHouse | Starting a Business in DC
VerdeHouse | Starting a Business in DCVerdeHouse | Starting a Business in DC
VerdeHouse | Starting a Business in DC
 
Venable | Starting a Business in DC
Venable | Starting a Business in DCVenable | Starting a Business in DC
Venable | Starting a Business in DC
 
Good or Evil: les fonctions anonymes en Javascript
Good or Evil: les fonctions anonymes en JavascriptGood or Evil: les fonctions anonymes en Javascript
Good or Evil: les fonctions anonymes en Javascript
 
DCRA | Registration & Licensing
DCRA | Registration & LicensingDCRA | Registration & Licensing
DCRA | Registration & Licensing
 
аллея доблести и славы редуктор
аллея доблести и славы редуктораллея доблести и славы редуктор
аллея доблести и славы редуктор
 
Starting a Franchise | Jones Day | Doing Business 2.0
Starting a Franchise | Jones Day | Doing Business 2.0Starting a Franchise | Jones Day | Doing Business 2.0
Starting a Franchise | Jones Day | Doing Business 2.0
 
Chale chalo
Chale chaloChale chalo
Chale chalo
 
Посібник для новобранців
Посібник для новобранцівПосібник для новобранців
Посібник для новобранців
 
CE Partners meeting Nrb enos_Swahili version
CE Partners meeting Nrb enos_Swahili versionCE Partners meeting Nrb enos_Swahili version
CE Partners meeting Nrb enos_Swahili version
 
Cells
CellsCells
Cells
 
Role of libraries in disasters and emergencies
Role of libraries in disasters and emergenciesRole of libraries in disasters and emergencies
Role of libraries in disasters and emergencies
 
Invitacion de cumpleaños
Invitacion de cumpleañosInvitacion de cumpleaños
Invitacion de cumpleaños
 
Pdhpe rationale
Pdhpe rationalePdhpe rationale
Pdhpe rationale
 
01
0101
01
 

Semelhante a Présentation de BackBone.JS

Aperçu de RequireJS
Aperçu de RequireJSAperçu de RequireJS
Aperçu de RequireJSVISEO
 
Softshake 2013 - Du JavaScript propre ? Challenge accepted!
Softshake 2013 - Du JavaScript propre ? Challenge accepted!Softshake 2013 - Du JavaScript propre ? Challenge accepted!
Softshake 2013 - Du JavaScript propre ? Challenge accepted!OCTO Technology
 
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!Softshake 2013 - Du JavaScript propre ? Challenge Accepted!
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!Romain Linsolas
 
Du JavaScript propre ? Challenge accepted!
Du JavaScript propre ? Challenge accepted!Du JavaScript propre ? Challenge accepted!
Du JavaScript propre ? Challenge accepted!OCTO Technology
 
Cours yeoman backbone box2d
Cours yeoman backbone box2dCours yeoman backbone box2d
Cours yeoman backbone box2dhugomallet
 
jQuery - GTI780 & MTI780 - ETS - A08
jQuery - GTI780 & MTI780 - ETS - A08jQuery - GTI780 & MTI780 - ETS - A08
jQuery - GTI780 & MTI780 - ETS - A08Claude Coulombe
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans DrupalAdyax
 
HTML5, Spring, NoSQL et mobilité
HTML5, Spring, NoSQL et mobilitéHTML5, Spring, NoSQL et mobilité
HTML5, Spring, NoSQL et mobilitéJulien Dubois
 
Angluars js
Angluars jsAngluars js
Angluars jsRYMAA
 
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon
 
Présentation jQuery pour débutant
Présentation jQuery pour débutantPrésentation jQuery pour débutant
Présentation jQuery pour débutantStanislas Chollet
 
Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptxEsokia
 

Semelhante a Présentation de BackBone.JS (20)

Aperçu de RequireJS
Aperçu de RequireJSAperçu de RequireJS
Aperçu de RequireJS
 
Softshake 2013 - Du JavaScript propre ? Challenge accepted!
Softshake 2013 - Du JavaScript propre ? Challenge accepted!Softshake 2013 - Du JavaScript propre ? Challenge accepted!
Softshake 2013 - Du JavaScript propre ? Challenge accepted!
 
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!Softshake 2013 - Du JavaScript propre ? Challenge Accepted!
Softshake 2013 - Du JavaScript propre ? Challenge Accepted!
 
Du JavaScript propre ? Challenge accepted!
Du JavaScript propre ? Challenge accepted!Du JavaScript propre ? Challenge accepted!
Du JavaScript propre ? Challenge accepted!
 
Cours yeoman backbone box2d
Cours yeoman backbone box2dCours yeoman backbone box2d
Cours yeoman backbone box2d
 
Backbonejs presentation
Backbonejs presentationBackbonejs presentation
Backbonejs presentation
 
Cours JavaScript
Cours JavaScriptCours JavaScript
Cours JavaScript
 
Javascript proprement
Javascript proprementJavascript proprement
Javascript proprement
 
jQuery - GTI780 & MTI780 - ETS - A08
jQuery - GTI780 & MTI780 - ETS - A08jQuery - GTI780 & MTI780 - ETS - A08
jQuery - GTI780 & MTI780 - ETS - A08
 
Systematic, toolchain JS
Systematic, toolchain JSSystematic, toolchain JS
Systematic, toolchain JS
 
EcmaScript
EcmaScriptEcmaScript
EcmaScript
 
Vert.x 3
Vert.x 3Vert.x 3
Vert.x 3
 
Java Server Faces 2
Java Server Faces 2Java Server Faces 2
Java Server Faces 2
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
 
HTML5, Spring, NoSQL et mobilité
HTML5, Spring, NoSQL et mobilitéHTML5, Spring, NoSQL et mobilité
HTML5, Spring, NoSQL et mobilité
 
Angluars js
Angluars jsAngluars js
Angluars js
 
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
Café Numérique Arlon S03#02: Je code mon blog (EU code week Arlon)
 
CV_Bilel CHAOUADI
CV_Bilel CHAOUADICV_Bilel CHAOUADI
CV_Bilel CHAOUADI
 
Présentation jQuery pour débutant
Présentation jQuery pour débutantPrésentation jQuery pour débutant
Présentation jQuery pour débutant
 
Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptx
 

Présentation de BackBone.JS

  • 1. Introduction à Backbone.JS @sylzys sylzys Sylvain Zyssman 29/05/2013 mardi 21 mai 13
  • 2. Backbone,  c’est  quoi  ? • Framework Javascript: M (Modèle) V (Vue) C (Collection) + Router • Une seule dépendance ferme (Underscore.js) • Compatible avec plusieurs moteurs de template mardi 21 mai 13
  • 3. Backbone,  pourquoi  ? • Principalement pour les Single Page Application • Navigation, formulaires ... gèrés en javascript • Evénements sur des changements de valeurs de nos modèles => rafraichissement automatiquement des vues •Possède son propre routeur mardi 21 mai 13
  • 4. Comment  ? Un modèle simple var Todo = Backbone.Model.extend({ defaults: { title:"backbone", language:"javascript" }, initialize: function(){ console.log('model initialized'); this.on('change:title', function(){ console.log("model title has changed"); }); } }); var my_todo = new Todo(); var my_todo_with_param({title : «Angular»}); my_todo.get(‘title’); my_todo_with_param.set({language : «JS»}); mardi 21 mai 13
  • 5. Backbone Methods extend constructor / initialize get set escape has unset clear id idAttribute cid attributes changed defaults toJSON sync fetch save destroy Underscore Methods validate validationError isValid url urlRoot parse clone isNew hasChanged changedAttributes previous previousAttributes mardi 21 mai 13
  • 6. Comment  ? Une vue simple var ListView = Backbone.View.extend({ el: $('body'), initialize: function(){ _.bindAll(this, 'render'); this.render(); }, render: function(){ $(this.el).append("<ul> <li>hello world</li> </ ul>"); } }); var listView = new ListView(); mardi 21 mai 13
  • 7. Backbone Methods extend constructor / initialize el $el setElement attributes $ (jQuery) render remove delegateEvents undelegateEvents mardi 21 mai 13
  • 8. Comment  ? Une collection simple var List = Backbone.Collection.extend({ model: Todo }); On apporte les modifications à la vue : • Déclaration dans la fonction «initialize» this.collection = new List(); this.collection.bind('add', this.appendItem); • Liaison de la collection et de la vue _(this.collection.models).each(function(item){ self.appendItem(item); }, this); mardi 21 mai 13
  • 9. Backbone Methods extend model constructor / initialize models toJSON sync Underscore Methods add remove reset set get at push pop unshift shift slice length comparator sort pluck where findWhere url parse clone fetch create mardi 21 mai 13
  • 11. Backbone,  et  après  ? Construits sur Backbone.js • Chaplin.js • Marionette.js D’autres frameworks Javascript • Angular.js • Ember.js • Batman.js • Knockout.js • ... mardi 21 mai 13
  • 12. Backbone,  des  liens  u9les •http://backbonejs.org/ •http://documentcloud.github.io/backbone/docs/backbone.html •http://bardevblog.wordpress.com/2012/12/04/re-learning-backbone- js/ •http://fr.clever-age.com/veille/blog/decouvrir-backbone-js-avec- todomvc.html •http://addyosmani.github.io/backbone-fundamentals/ mardi 21 mai 13