SlideShare a Scribd company logo
1 of 26
Download to read offline
Backbone.js
Introduction / Oren Farhi
Oren Farhi
Front End Architect, JS Engineer @Tikal
JS Group Leader - Meet, Share, Contribute & Coding
Speaker (Israel & World Wide)
Developing with:
Pure Javascript, Backbone.js, Underscore.js, jQuery, CSS3
github.com/tikalk
@tikalk
We help companies build, deliver,
deploy, manage and optimize their products.
JAVA JS RoR.NETALM
“Today we are SURE that we made the right
decision, choosing Tikal”
Guy Ben-Porat - Development Manager “ExLibris”
Tikal by Numbers
“Actions speak louder than words”
Tikal's motto
1600+
Community
Members
150+
Blog Posts
Last Year
460+
Meetup
Members
100+
Projects
Last Year
90+
Tikal’s
Experts Team
12+
Years old
The Past:
JS is the wild west
No code conventions
jQuery bloated code
Data & DOM mixed
jQuery ajax & callbacks are a
bit messy
No Reuse
Most End Result:
words and sentences with
long selectors and "hanged"
functions everywhere
The Present: All we have is now
Simplicity
Organization
Focus
Backbone Background
Jeremy Ashkenas -
Underscore, Coffeescript
DocumentCloud
Dependencies:
jquery / zepto
underscore.js
json2.js ( IE, other without JSON )
Backbone is:
MVC library (MIT)
Structure
RESTful JSON connector
Hash Routing Engine
Event Driven
Extended
Model
Events
View
Collection
Router
Utilities - based underscore.js
Templating Engine - based underscore.js
What is it good for?
Linkedin Mobile, SoundCloud, Foursquar,
Khan Academy, Airbnb, Rdio, Hulu
Structure for Code
Separation of Concerns
Modular, Extensible
Reusable Modules
Loose Coupling
Model Driven
Unit Test Ready
M - Backbone.Model
V - _.template
C - Backbone.View / Router
This is a backbone.
When used properly
It keeps one's head
Out of one's butt
Rand Macivor
What we're going to do today:
https://github.com/tikalk/backbone-workshop
Backbone.Model
Where JSON data is stored
REST, Constructor, Manually
Data Change Events
Works With: Collection, View
Methods:
set - validate
get
escape
clear
fetch
save (REST) - parse
destroy (REST)
Backbone.Model
Backbone.Model - PRACTICE
Model properties: defaults,
Model Methods: initialize, set, get
Backbone.View
A Controller for a DOM Element (wrapper)
Renders Model/Collection to DOM (html)
Delegates DOM Events
Works With: Model, Collection
Can use Any template engine to render
html
Methods:
render (return this)
make
remove
un/delegateEvents
Properties:
$ = $el.find
el
$el
options
events
Backbone.View
Backbone.View - PRACTICE
View properties: events, tagName, className, render
_.Underscore.js
Utilities for Javascript (60)
Collections, Arrays, Functions, Objects,
Uses Browsers Implementation if possible
High Expressiveness
Works With: Backbone, Standalone
Methods:
Collections - each, map, filter, pluck,
groupBy
Arrays - without, uniq
Functions - bind, debounce,
Object - keys, values, is-* (Empty, Date,
String, Function etc..), has
Utility - template, escape, mixin
Chaining - chain, value
_.Underscore.js
Backbone.Collection
Collection of Models
REST, Constructor, Manually
Inherits Change Events from Models
Works With: Model, View
Many utilities methods from underscore.js
Methods:
add
remove
length
fetch
save (REST) - parse
destroy (REST)
+ 28 Underscore methods:
map, find, filter, sortBy, groupBy, pluck,
invoke ...
Properties:
options
Backbone.Collection
Backbone.Collection - PRACTICE
Backbone.Router
Navigation Handling (bookmarks)
Listens to url change events
Natively integrated to Back/Forward
Easy routing handling
Works With: Backbone.History
Methods:
custom
navigate
route (create)
Properties:
routes (key - value) - (route - handler)
Backbone.Router
Backbone.Router - PRACTICE
Questions?
Backbone - http://documentcloud.github.com/backbone/
Underscore - http://documentcloud.github.com/underscore
Tikal - http://www.tikalk.com

More Related Content

Similar to Backbone.js introduction workshop

Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal Knowledge
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersElena-Oana Tabaranu
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Backbone web apps - design & architecture
Backbone web apps  - design & architectureBackbone web apps  - design & architecture
Backbone web apps - design & architectureOren Farhi
 
Backbone.js Architecture Example - Echoes Media Player (Hebrew)
Backbone.js Architecture Example - Echoes Media Player (Hebrew)Backbone.js Architecture Example - Echoes Media Player (Hebrew)
Backbone.js Architecture Example - Echoes Media Player (Hebrew)Yifat Kanfi
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptjasonsich
 
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source CodeHadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Codejimfuller2009
 
Intro to-html-backbone
Intro to-html-backboneIntro to-html-backbone
Intro to-html-backbonezonathen
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
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
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBJustin Smestad
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildwebLeo Zhou
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008geraldbauer
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
Organized web app development using backbone.js
Organized web app development using backbone.jsOrganized web app development using backbone.js
Organized web app development using backbone.jsShakti Shrestha
 

Similar to Backbone.js introduction workshop (20)

Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshop
 
Backbonejs on Rails
Backbonejs on RailsBackbonejs on Rails
Backbonejs on Rails
 
Play framework
Play frameworkPlay framework
Play framework
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBusters
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Backbone web apps - design & architecture
Backbone web apps  - design & architectureBackbone web apps  - design & architecture
Backbone web apps - design & architecture
 
Backbone.js Architecture Example - Echoes Media Player (Hebrew)
Backbone.js Architecture Example - Echoes Media Player (Hebrew)Backbone.js Architecture Example - Echoes Media Player (Hebrew)
Backbone.js Architecture Example - Echoes Media Player (Hebrew)
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
 
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source CodeHadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
Hadoop and Marklogic: Using the Genetic Algorithm to generate Source Code
 
Intro to-html-backbone
Intro to-html-backboneIntro to-html-backbone
Intro to-html-backbone
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
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...
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Organized web app development using backbone.js
Organized web app development using backbone.jsOrganized web app development using backbone.js
Organized web app development using backbone.js
 

More from Yifat Kanfi

Tikal fullstack-he
Tikal fullstack-heTikal fullstack-he
Tikal fullstack-heYifat Kanfi
 
Tikal's front-end career path
Tikal's front-end career pathTikal's front-end career path
Tikal's front-end career pathYifat Kanfi
 
Tikal's technology career
Tikal's technology careerTikal's technology career
Tikal's technology careerYifat Kanfi
 

More from Yifat Kanfi (6)

Tikal fullstack-he
Tikal fullstack-heTikal fullstack-he
Tikal fullstack-he
 
Tikal's front-end career path
Tikal's front-end career pathTikal's front-end career path
Tikal's front-end career path
 
Tikal's technology career
Tikal's technology careerTikal's technology career
Tikal's technology career
 
Tikal Career
Tikal CareerTikal Career
Tikal Career
 
Tikal Career
Tikal CareerTikal Career
Tikal Career
 
Tikal hr
Tikal hrTikal hr
Tikal hr
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 

Backbone.js introduction workshop

  • 2. Oren Farhi Front End Architect, JS Engineer @Tikal JS Group Leader - Meet, Share, Contribute & Coding Speaker (Israel & World Wide) Developing with: Pure Javascript, Backbone.js, Underscore.js, jQuery, CSS3 github.com/tikalk @tikalk
  • 3. We help companies build, deliver, deploy, manage and optimize their products. JAVA JS RoR.NETALM “Today we are SURE that we made the right decision, choosing Tikal” Guy Ben-Porat - Development Manager “ExLibris”
  • 4. Tikal by Numbers “Actions speak louder than words” Tikal's motto 1600+ Community Members 150+ Blog Posts Last Year 460+ Meetup Members 100+ Projects Last Year 90+ Tikal’s Experts Team 12+ Years old
  • 5. The Past: JS is the wild west No code conventions jQuery bloated code Data & DOM mixed jQuery ajax & callbacks are a bit messy No Reuse Most End Result: words and sentences with long selectors and "hanged" functions everywhere
  • 6. The Present: All we have is now Simplicity Organization Focus
  • 7. Backbone Background Jeremy Ashkenas - Underscore, Coffeescript DocumentCloud Dependencies: jquery / zepto underscore.js json2.js ( IE, other without JSON )
  • 8. Backbone is: MVC library (MIT) Structure RESTful JSON connector Hash Routing Engine Event Driven Extended Model Events View Collection Router Utilities - based underscore.js Templating Engine - based underscore.js
  • 9. What is it good for? Linkedin Mobile, SoundCloud, Foursquar, Khan Academy, Airbnb, Rdio, Hulu Structure for Code Separation of Concerns Modular, Extensible Reusable Modules Loose Coupling Model Driven Unit Test Ready M - Backbone.Model V - _.template C - Backbone.View / Router
  • 10. This is a backbone. When used properly It keeps one's head Out of one's butt Rand Macivor
  • 11. What we're going to do today: https://github.com/tikalk/backbone-workshop
  • 12. Backbone.Model Where JSON data is stored REST, Constructor, Manually Data Change Events Works With: Collection, View Methods: set - validate get escape clear fetch save (REST) - parse destroy (REST)
  • 14. Backbone.Model - PRACTICE Model properties: defaults, Model Methods: initialize, set, get
  • 15. Backbone.View A Controller for a DOM Element (wrapper) Renders Model/Collection to DOM (html) Delegates DOM Events Works With: Model, Collection Can use Any template engine to render html Methods: render (return this) make remove un/delegateEvents Properties: $ = $el.find el $el options events
  • 17. Backbone.View - PRACTICE View properties: events, tagName, className, render
  • 18. _.Underscore.js Utilities for Javascript (60) Collections, Arrays, Functions, Objects, Uses Browsers Implementation if possible High Expressiveness Works With: Backbone, Standalone Methods: Collections - each, map, filter, pluck, groupBy Arrays - without, uniq Functions - bind, debounce, Object - keys, values, is-* (Empty, Date, String, Function etc..), has Utility - template, escape, mixin Chaining - chain, value
  • 20. Backbone.Collection Collection of Models REST, Constructor, Manually Inherits Change Events from Models Works With: Model, View Many utilities methods from underscore.js Methods: add remove length fetch save (REST) - parse destroy (REST) + 28 Underscore methods: map, find, filter, sortBy, groupBy, pluck, invoke ... Properties: options
  • 23. Backbone.Router Navigation Handling (bookmarks) Listens to url change events Natively integrated to Back/Forward Easy routing handling Works With: Backbone.History Methods: custom navigate route (create) Properties: routes (key - value) - (route - handler)
  • 26. Questions? Backbone - http://documentcloud.github.com/backbone/ Underscore - http://documentcloud.github.com/underscore Tikal - http://www.tikalk.com