SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Building Bridges, Connecting Communities
VADIM MIRGOROD
Front-end, 05/22/2013
Using Backbone.js with
Drupal 7 and 8
Vadim Mirgorod
• Lead developer in Trellon
• Writing Backbone.js CookBook for PACKT
• Email: dealancer@gmail.com
• Web: http://vmirgorod.name
• Twitter: @dealancer
#2
Remember the web 
development in 90s?
#3
1995: JavaScript
#4
2000: XMLHttpRequest
#5
2006: jQuery
#6
2013:
?
#7
What's new in JS?
• HTML5:
– Local Storage
– pushState
• JS templating engines:
– Mustache.js
– Twig.js
• Representative State Transfer (REST)
#8
JavaScript client 
evolution
#9
Complexity
#10
Thin to thick transition
#11
Performance
#12
Problems!
Right now typical AJAX 
code looks like this
$(document).ready(function() {
$("#getData").click( function() {
$.getJSON("artistsRemote.cfc?
method=getArtists&returnformat=json",
function(data) {
$("#artistsContent").empty();
$
("#artistsTemplate").tmpl( data ).appendTo("#artistsContent");
var nowIs = new Date().toLocaleString();
$('#lastLoad').html( nowIs );
});
});
});
#14
AJAX in Drupal
Have you seen any JS?
#15
#16
Let's do things properly!
#17
Meet...
#18
#19
Backbone.js
• URL: http://backbonejs.org/
• Created by Jeremy Ashkenas in 2010, an author of
CoffeeScript
• Based on Underscore.js: http://backbonejs.org/
• Requires jQuery or Zepto
#20
Backbone.js features
• Minimalistic
• Modular
• Perfect OOP design
• Over 100 available extensions:
https://github.com/documentcloud/backbone/wiki/Extension
• Community
#21
Backbone vs...
• Knockout
• AngularJS
• CanJS
• Spine
• Ember.js
• many others
#22
Backbone vs...
#23
Who uses Backbone.js?
• Groupon Now!
• Foursquare
• LinkedIn Mobile
• Airbnb
#24
Let's learn how to 
backbone!
#25
Main concepts
• Model
• Collection
• View
• Template
• Router
• History
• Events
#26
MVC: Backbone:
http://www.jboss.org/jdf/examples/ticket-monster/tutorial/UserFrontEnd/#27
DEMO!
TODO APP
#28
Easy example
Define the model and 
the collection
// Define new model.
var InvoiceItemModel = Backbone.Model.extend({
calculateAmount: function() {
return this.get('price') * this.get('quantity');
}
});
// Define new collection object.
var InvoiceItemCollection = Backbone.Collection.extend({
model: InvoiceItemModel
});
#30
Define the view to 
render the model
var InvoiceItemView = Backbone.View.extend({
// Define element tag name.
tagName: 'tr',
// Define template.
template: _.template($('#item-row-template').html()),
// Render the view.
render: function() {
var data = this.model.toJSON();
data.amount = this.model.calculateAmount();
$(this.el).html(this.template(data));
return this;
},
});
#31
Define the view to 
render the collection
var InvoiceItemListView = Backbone.View.extend({
tagName: 'table',
template: _.template($('#item-table-template').html()),
// Render the view.
render: function() {
$(this.el).html(this.template());
_.each(this.collection.models, function(model, key)
{ this.append(model); }, this);
return this;
},
// Add an invoice item row to the table.
append: function(model) {
$(this.el).append(new InvoiceItemView({ model: model }).render().el);
}
});#32
Add templates into 
index.html
<script type="text/html" class="template" id="item-table-
template">
<tr>
<th>Quantity</th>
<th>Description</th>
<th>Price</th>
<th>Amount</th>
</tr>
</script>
<script type="text/html" class="template" id="item-row-
template">
<td><%= quantity %></td>
<td><%= description %></td>
<td><%= price %></td>
<td><%= amount %></td>#33
Create collection and 
show the view
var invoiceItemCollection = new InvoiceItemCollection([
{ description: 'Wooden Toy House', price: 22, quantity:
3 },
{ description: 'Farm Animal Set', price: 17, quantity: 1 },
]);
$('body').html(new InvoiceItemListView({
collection: invoiceItemCollection }).render().el
);
#34
Some cool things
Two way binding
Model to view binding
Layouts
TemplatesRouter
Forms
Model to view binding
var InvoiceItemView = Backbone.View.extend({
// ...
initialize: function() {
this.listenTo(this.model, 'destroy', this.destroy, this);
this.listenTo(this.model, 'change', this.render, this);
},
destroy: function() { this.remove(); }
});
var InvoiceItemListView = Backbone.View.extend({
// ...
initialize: function() {
this.listenTo(this.collection, 'add', this.append, this);
}
});
#36
Forms
// Backbone-forms extension.
var UserModel = Backbone.Model.extend({
schema: {
title: { type: 'Select', options: ['Mr', 'Mrs',
'Ms'] },
name: 'Text',
email: { validators: ['required', 'email'] },
password: 'Password',
birthday: 'Date',
}
});
userModel = new BuyerModel();
$('body').append(new Backbone.Form({ model:
this.user }).form.render().el);#37
Two­way binding
// Backbone.stickit extension.
var InvoiceItemFormView = Backbone.View.extend({
className: 'invoice-item-form-view',
bindings: {
'#description': 'description',
'#price': 'price',
'#quantity': 'quantity'
},
render: function() {
var html = '<label>Description:</label><input type="text"
id="description"></input><br>' +
'<label>Price:</label><input type="text" id="price"></input><br>' +
'<label>Quantity:</label><input type="text" id="quantity"></input><br>';
$(this.el).html(html);
// Here binding occurs.
this.stickit();
return this;#38
Forms
// Backbone-forms extension.
var UserModel = Backbone.Model.extend({
schema: {
title: { type: 'Select', options: ['Mr', 'Mrs',
'Ms'] },
name: 'Text',
email: { validators: ['required', 'email'] },
password: 'Password',
birthday: 'Date',
}
});
userModel = new BuyerModel();
$('body').append(new Backbone.Form({ model:
this.user }).form.render().el);#39
Router
var Workspace = Backbone.Router.extend({
routes: {
// Default path.
'': 'invoiceList',
// Usage of static path.
'invoice': 'invoiceList',
// Usage of fragment parameter.
'invoice/:id': 'invoicePage',
// Usage of fragment parameters.
'help/:topic/page:page': 'helpPage',
// Usage of splat parameter.
'download/*path': 'downloadPage'
},
});
#40
Other cool things...
in Backbone.js Cookbook
• Bootstrapping:
– Technique we saw above
– Do it yourself
• Representational State Transfer:
– Services module
– RESTful webservices module
• Backbone.js module
Backbone and Drupal 7
#43
REST
#44
REST in Backbone
var PostModel = Backbone.Model.extend({
// Override id attribute.
idAttribute: '_id',
// Define URL root to access model resource. Otherwise use
// url() method to provide full path to the model resource.
urlRoot: function() { return 'http://example.com/posts/'; }
});
var PostCollection = Backbone.Collection.extend({
model: PostModel,
// Define path to the collection resource.
url: function() { return 'http://example.com/posts/'; }
});
#45
REST in Backbone.js
// Fetches data into a model.
model.fetch();
// Saves a model.
model.save();
// Destroys a model.
model.destroy();
// Fetches data into a collection.
collection.fetch();
// Adds models to a collection.
collection.add(models);
// Removes specific models from collection.
collection.remove(models);
#46
Backbone module
• URL: http://drupal.org/project/backbone
• Provides models and collections for Drupal entities
via REST:
– Node: Node model
– All node: NodeIndex collection
– Arbitrary view: NodeView collection
• Works with both Services and RESTful Web Services
modules.
#47
Backbone module
// Create new NodeView collection.
var viewCollection = new
Drupal.Backbone.Collections.NodeView();
// Set Drupal View name.
viewCollection.viewName = 'backbone_example';
// Fetch data from the collection.
viewCollection.fetch({success: function() {
console.log(viewCollection.toJSON());
});
#48
Backbone mdl roadmap
• Support for bootstrapping
• Better views support
• In-place content editing
• Drag and Drop
• D8 version?
#49
http://www.flickr.com/photos/gabblebee/3977912731/
Backbone and Drupal 8
• It is in core!
• Used for In-place editing issue:
http://drupal.org/node/1824500
• Used for layouts issue:http://drupal.org/node/1841584
• Used for toolbar issue:http://drupal.org/node/1860434
• META issue: http://drupal.org/node/1858368
#51
DEMO!
One more thing!
• Web services initiative
– REST in core
– Storage controllers
• Twig
– Templating engine
– Twig in core (Twig sandbox)
– Works both for PHP and JS
#53
One more thing!
#54
Twig templates
Storage controllers
Access controllers
Render controllers
Form controllers
DBBrowser
One more thing!
#55
Backbone app
Twig templates
Storage controllers
Access controllers
Render controllers
Form controllers
DB
REST
Browser
One more thing!
#56
Backbone app
Twig templates
Storage controllers
Access controllers
Render controllers
Form controllers
DB
REST
Browser
Mobile
One more thing!
#57
Backbone app
Twig templates
Storage controllers
Access controllers
DB
REST
Mobile app built with PhoneGap or Trigger.io
Building Bridges, Connecting Communities
Evaluate this session at:
 portland2013.drupal.org/node/1578. 
Thank you!
What did you think?

Weitere ähnliche Inhalte

Was ist angesagt?

Backbone beyond jQuery
Backbone beyond jQueryBackbone beyond jQuery
Backbone beyond jQueryAdam Krebs
 
The Mobile Development Landscape
The Mobile Development LandscapeThe Mobile Development Landscape
The Mobile Development LandscapeAmbert Ho
 
Realtime web apps rails
Realtime web apps railsRealtime web apps rails
Realtime web apps railsAmbert Ho
 
Go Fullstack: JSF for Public Sites (CONFESS 2013)
Go Fullstack: JSF for Public Sites (CONFESS 2013)Go Fullstack: JSF for Public Sites (CONFESS 2013)
Go Fullstack: JSF for Public Sites (CONFESS 2013)Michael Kurz
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friendsGood Robot
 
Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersAoteaStudios
 
Go Fullstack: JSF for Public Sites (CONFESS 2012)
Go Fullstack: JSF for Public Sites (CONFESS 2012)Go Fullstack: JSF for Public Sites (CONFESS 2012)
Go Fullstack: JSF for Public Sites (CONFESS 2012)Michael Kurz
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverSpike Brehm
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications Rohan Chandane
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalCampDN
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSDen Odell
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & AngularAlexe Bogdan
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone frameworkfrontendne
 
Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Richard Powell
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the clientSebastiano Armeli
 
Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Stéphane Bégaudeau
 

Was ist angesagt? (20)

Backbone beyond jQuery
Backbone beyond jQueryBackbone beyond jQuery
Backbone beyond jQuery
 
The Mobile Development Landscape
The Mobile Development LandscapeThe Mobile Development Landscape
The Mobile Development Landscape
 
Realtime web apps rails
Realtime web apps railsRealtime web apps rails
Realtime web apps rails
 
Go Fullstack: JSF for Public Sites (CONFESS 2013)
Go Fullstack: JSF for Public Sites (CONFESS 2013)Go Fullstack: JSF for Public Sites (CONFESS 2013)
Go Fullstack: JSF for Public Sites (CONFESS 2013)
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friends
 
Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developers
 
Go Fullstack: JSF for Public Sites (CONFESS 2012)
Go Fullstack: JSF for Public Sites (CONFESS 2012)Go Fullstack: JSF for Public Sites (CONFESS 2012)
Go Fullstack: JSF for Public Sites (CONFESS 2012)
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone framework
 
Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
 
Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Vue, vue router, vuex
Vue, vue router, vuexVue, vue router, vuex
Vue, vue router, vuex
 

Ähnlich wie Backbone js-slides

Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Ovadiah Myrgorod
 
Backbonejs for beginners
Backbonejs for beginnersBackbonejs for beginners
Backbonejs for beginnersDivakar Gu
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Revath S Kumar
 
Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsPrateek Dayal
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.jsBert Wijnants
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
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
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel.NET Conf UY
 
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
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSAkshay Mathur
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applicationsDivyanshGupta922023
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmersAlexander Varwijk
 

Ähnlich wie Backbone js-slides (20)

Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Backbonejs for beginners
Backbonejs for beginnersBackbonejs for beginners
Backbonejs for beginners
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02
 
Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and Rails
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
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...
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular 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!
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
 
Vue business first
Vue business firstVue business first
Vue business first
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmers
 

Mehr von DrupalCamp Kyiv Рысь

система управления конфигурацией в Drupal 8. анализ результатов изменений.
система управления конфигурацией в Drupal 8. анализ результатов изменений.система управления конфигурацией в Drupal 8. анализ результатов изменений.
система управления конфигурацией в Drupal 8. анализ результатов изменений.DrupalCamp Kyiv Рысь
 
ознакомления с модулем Entity api
ознакомления с модулем Entity apiознакомления с модулем Entity api
ознакомления с модулем Entity apiDrupalCamp Kyiv Рысь
 
Drupal 7 и history.js или как ajax инфицировать сайт
Drupal 7 и history.js или как ajax инфицировать сайтDrupal 7 и history.js или как ajax инфицировать сайт
Drupal 7 и history.js или как ajax инфицировать сайтDrupalCamp Kyiv Рысь
 
Cdn hosting решения для drupal (medium)
Cdn hosting   решения для drupal (medium)Cdn hosting   решения для drupal (medium)
Cdn hosting решения для drupal (medium)DrupalCamp Kyiv Рысь
 
Aegir. развертывание и управление большой сетью drupal сайтов
Aegir. развертывание и управление большой сетью drupal сайтовAegir. развертывание и управление большой сетью drupal сайтов
Aegir. развертывание и управление большой сетью drupal сайтовDrupalCamp Kyiv Рысь
 

Mehr von DrupalCamp Kyiv Рысь (17)

Drupal association slides us 2013
Drupal association slides us 2013Drupal association slides us 2013
Drupal association slides us 2013
 
Drupal association slides ru
Drupal association slides ruDrupal association slides ru
Drupal association slides ru
 
#D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8 #D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8
 
Game of-sales-presentation
Game of-sales-presentationGame of-sales-presentation
Game of-sales-presentation
 
система управления конфигурацией в Drupal 8. анализ результатов изменений.
система управления конфигурацией в Drupal 8. анализ результатов изменений.система управления конфигурацией в Drupal 8. анализ результатов изменений.
система управления конфигурацией в Drupal 8. анализ результатов изменений.
 
симфони это не страшно
симфони   это не страшносимфони   это не страшно
симфони это не страшно
 
ознакомления с модулем Entity api
ознакомления с модулем Entity apiознакомления с модулем Entity api
ознакомления с модулем Entity api
 
Services в drupal 8
Services в drupal 8Services в drupal 8
Services в drupal 8
 
Facet api
Facet apiFacet api
Facet api
 
Facet api
Facet apiFacet api
Facet api
 
Erpal erp with drupal
Erpal   erp with drupalErpal   erp with drupal
Erpal erp with drupal
 
Drupal 8 theming principles
Drupal 8 theming principlesDrupal 8 theming principles
Drupal 8 theming principles
 
Drupal 7 и history.js или как ajax инфицировать сайт
Drupal 7 и history.js или как ajax инфицировать сайтDrupal 7 и history.js или как ajax инфицировать сайт
Drupal 7 и history.js или как ajax инфицировать сайт
 
Cdn hosting решения для drupal (medium)
Cdn hosting   решения для drupal (medium)Cdn hosting   решения для drupal (medium)
Cdn hosting решения для drupal (medium)
 
Aegir. развертывание и управление большой сетью drupal сайтов
Aegir. развертывание и управление большой сетью drupal сайтовAegir. развертывание и управление большой сетью drupal сайтов
Aegir. развертывание и управление большой сетью drupal сайтов
 
Behat
BehatBehat
Behat
 
что нового в мире Services
что нового в мире Servicesчто нового в мире Services
что нового в мире Services
 

Kürzlich hochgeladen

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Kürzlich hochgeladen (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Backbone js-slides

Hinweis der Redaktion

  1. Dear ladies and gentlemen. Welcome on the Backbone.js session.
  2. My name is Vadim and I am a lead developer in Trellon. Currently I am writing Backbone.js CooBook for the PACKT Publishing. I am completing finale chapters and I hope it will be punished very soon. If you want to have a discount, please, contact me via email or twitter so I can provide you voucher.
  3. Do you remember those lovely days when everybody was using DHTML pages with some JavaScript inside? For example there were so many scripts that checked if the form was correctly filled and showed dialog boxes if it is not.
  4. Just remind how fun it was in 1995! Actually I started to use Internet in 1999, when I was still in school. There was no so many JavaScript powered web pages, but it was very cool to see snowflakes floating on the screen on the Merry Christmas eve! This is how JS was used at this time.
  5. And then in 2000 Microsoft invented XMLHttpRequest. 5 years (!) had been passed since we called it AJAX. Incredible, but in 1998 people were using iframes to do the same!
  6. In 2006 we first saw jQuery. It was awesome! It allowed do so many new things: * Use CSS selectors for DOM traversing * Do vent handling * Perform AJAX * Make animation * Achieve compatibility with old browsers It was amazing! BTW is is going to be jQuery conference in Portland soon: on June 13 &amp; 14 this year.
  7. And what we are working with in the 2013? There are so many new things that have appeared during recent years. Now it is time remind them.
  8. Alright! * Now we have HTML5 that provides so many cool things. * Fore example in HTML5 there is Local Storage and if is used, your application can keep data in the browser storage when there is no Internet connection, and synchronize data with a remote server when connection is available. * Push state allows to update URL in the browser without need to reload the page.. Remember that before we used # in the URL to be able to change. And now not, this gives us some possibilities to create Search Engines compatible dynamic web apps. * Now we also have JS templating engines on the client-side that allows to unload the server and to transfer JSON instead of HTML code. * We also have REST (Representational State Transfer), which is an architectural style which implies that server deals with data, while client is involved into interaction with a user. With REST we can easily replace the server or the client with alternative server or a cleint.
  9. And what about JS evolution seen last years.
  10. First, clients is eacoming more complex be able to do much more things then ever before.
  11. Second, they became more thick, may contain some business logic and, obviously, perform rendering. Server just stores data and checks access permissions. Also just want to note, that we are seeing this thin-to-thick clients transition once again. TODO: In Unix time there was X Windows System that allowed user to access server resources, and client was very thin.
  12. And third, browsers executes JavaScript 10 times faster then it was 10 years ago. JS client applications works really fast now! And even performance on mobile devices is not bad.
  13. But we still have some problems!
  14. Right now typical AJAX code looks like this. And there is something wrong about it! Here we do: a) Event handling b) AJAX request c) Data rendering d) DOM updates That&apos;s to much for the single piece of code! This code looks the same as it was when developers where creating first desktop programs at the dawn of programming. Or the same as website development when there was no many MVC frameworks for the web.
  15. Also, AJAX in Drupal. Have you ever deal with any JavaScript when building AJAX application with Drupal? There is cool form API, AHAH, we are defining AJAX settings in PHP arrays.
  16. D&apos;oh!
  17. Let&apos;s do things properly! Can we? I mean use just JavaScript when it is intended to be used, and use proper MVC framework so there is no mess in the code. Yeah, there is a way!
  18. Meet! ... Backbone... JS!
  19. Whoohoo!
  20. Backbone.js was created by Jeremy Ashkenas, author of the CoffeScript in 2010. Backbone.js is based on the Undersore.js library which provides many useful functions to work with arrays, collections, objects, events, and so on. Backbone.js requires jQuery or Zepto Zepto is 99% compatible with jQuety, which is smaller and faster but works only in modern browsers.
  21. Let&apos;s speak about Backbone.js advantages. * It is minimalistic and easy integrates with other frameworks. * It is modular, which means you can use only required functionality. * It also has perfect OOP design and can be easily extended and overridden * Also there is a growing amount of Backbone.js extension. And now it is more then 100. * And there is a nice community. 90% of my issues I created on GitHub received feedback. This is really great. Community grows the day after the day. And I like it.
  22. There are many similar frameworks, why we are speaking about Backbone.js now?
  23. Because you should now how new frameworks appears. Look at this slide!
  24. And finally Backbone.js was chosen by many world knows startups and websites. * Groupon Now!&apos;s team decided their first product to be AJAX heavy, but still linkable and shareable. Despite they were completely new in Backbone, they found it&apos;s learning curve was incredible quick, so they were able to deliver the working product just in two weeks. * Foursquare used Backbone.js library to create model classes for the entities in foursquare (e.g. venues, checkins, users). They found that Backbone’s model classes provide a simple and lightweight mechanism to capture object data and state, complete with the semantics of classical inheritance. * LinkedIn Mobile used Backbone.js to create it&apos;s ts next-generation HTML5 mobile web app. Backbone made it easy to keep the app modular, organized and extensible so that it was possible to program the complexities of LinkedIn&apos;s user experience. * Airbnb is a community marketplace for users to list, discover, and book unique spaces around the world. Development team uses Backbone in many latest products. Recently they rebuilt mobile website with Backbone.js and Node.js tied together with a library they&apos;re calling Rendr.
  25. Let&apos;s learn how to create backbone applications.
  26. Backbone.js operates with following objects * Model contains data and provides business logic used in the application. * Collection is a set of models that can be processed in the loop and supports sorting and filtering. * View renders model or collection and interacts with the user. * Templates are used for separation HTML from JavaSript in the View. By default Undescore template engine is used, but it can be replaced with Twig, which is used in Drupal 8 or Mustache. * Router is similar to hook_menu. It allows to define a path and provide callbacks. * History is global object, which contains router that is currently in use. * Backbone objects such as Models, Collections, Views and Router implements Events object, they can provide own events and listen to events from other objects.
  27. There are some differences in Backbone architecture and traditional MVC pattern. At the left there is a MVC structure . Here we see, that the Model updates the View seen by the user. User can perform actions which are handled by the Controller. Controller manipulates model data and can trigger business logic methods. Also Models is synchronized with a storage. At the right you can see Backbone.js structure. The main difference is that some of the controller functionality is implemented by the View, while other by the router. Typically view can listen model events and update DOM. View also listens to user events and updates model accordingly. Model is synchronized with a server using REST approach. Read ops are typically controlled by the Router, while write ops by the View.
  28. Let&apos;s make some demo!
  29. Let&apos;s start with some easy example. Here we just render the collection of models with Backbone.js.
  30. Now we can move forward and learn how to add some cool features into our application.
  31. Here is how we can use REST with our models and collections.
  32. Here is how we can use REST with our models and collections.
  33. Here is how we can use REST with our models and collections.
  34. Here is how we can use REST with our models and collections.
  35. Here is how we can use REST with our models and collections.
  36. Some other cool things you will find in Backbone.js CookBook. I am working on final chapters and soon the book will be published. Contact me or leave your business card please, so I can provide you with a discount voucher.
  37. Ok, now let&apos;s understand how Backbone deals with Drupal.
  38. To pass data from Drupal to Backbone.js we can use following methods. Bootstrapping. This is the technique we saw above: we can create model and collection objects and populate them with data directly in JS code. In D7 we can pass data as settings into JS code. (TODO: add example). REST (Representational State Transfer) – is an architectural style for designing network applications which communicate between each other using HTTP protocol and passing data in JSON format or any other appropriate HTTP data type. In this case Backbone.js client and Drupal synchronizes data via REST. In Drupal 7 RESTful service can be implemented using Services / RESTful web-services modules. Backbone module provides more convenient way for Backbone client to communicate with Drupal. It is also based on the REST approach. Let&apos;s see how those approaches works in detail.
  39. Let&apos;s understand how REST works. REST-style architectures consists of clients and servers. Client calls HTTP request method (POST, GET, PUT, DELETE) to perform CRUD (created, read, update, delete) operation over a resource, which can be either a collection or a single element. There can be a resource that represents multiple or single object. Depending on the request and resource type one or another operation can be performed. Following table shows it.
  40. Here is how we can use REST with our models and collections.
  41. Here is how we can use REST or our models and collections.
  42. Here is one more way of dealing with Backbone.js in Drupal. There is Drupal module called Backbone that can provide node, comment and user entities on the client side where Backbone is running. It works via REST and integrates with both Services and RESTful web services modules. It also provides lists of users and nodes and even content of Drupal view to the Backbone app! This module just saves much time.
  43. Let&apos;s see how it works. As we said before Backbone is pretty extensible, so we extend default models and collections. This example shows how we can get Drupal entities from the View and work with them as with Backbone Collection. We simply need to know view name and nothing else to get those entities. That&apos;s really cool! Thanks to ****, author of this module.
  44. This module is still in development, which means that there will be many new features. Such as bootstrapping support, better views support. It will allow to do in-place content editing, drag and drop support to reorder things. And may be we will see D8 version.
  45. Guess how Bakcbone.js is related to Drupal8?
  46. It&apos;s in core! Along with other libraries such as jQuery or jQuery UI! It is event in D8 Wow! Some of the existing functionality is completely being rebuilt using Backbone.js: in-place editing, layouts, toolbar and many other. You can refer to the following links to understand what&apos;s going on in D8. You can also take part in the Drupal Code sprint at Friday.
  47. One more thing we need to talk about. Drupal 8 is now much powerful then it was. It is based on Symphony and uses much more OOP then ever before. There can be controller class for operating with entities, configuration, permissions and other data stored in the system. Now logic is completely separated from the representation. And it is quite easy module to define REST resources to access it&apos;s data. So REST support is in core and will basically provided by any Drupal 8 module. Also Twig is in core too. Twig is a templating engine that is brought to Drupal 8 to provide better security and convenience when doing theming. There is also Twig implementation for JS.
  48. This is very simplified scheme of how things will work in D8.
  49. Let&apos;s imagine that we can use Twig templates on the client side. This means that we can easily re-do some of the front-end functionality with Backbone.js.
  50. And it would work for mobile too.
  51. Even more, we can wrapp such application in a mobile app with PhoneGap or Trigger.io. Those tools allows to build mobile application from HTML5 / CSS3 / JS.