SlideShare a Scribd company logo
1 of 17
Building Single Page
       Web Apps
A symphony of Rails, CoffeeScript and Backbone.js


              Vagmi Mudumbai
    @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Why Single Page Apps?




       Fast & Sexy   @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Made for each other
              @vagmi | fb.com/vagmi | bit.ly/plusvagmi
JS and its Good Parts




                @vagmi | fb.com/vagmi | bit.ly/plusvagmi
CoffeeScript




   Jeremy
                   Douglas
“CoffeeScript”
                 “Javascript”
  Ashkenas
                 Crockford
                     @vagmi | fb.com/vagmi | bit.ly/plusvagmi
CoffeeScript
countdown = (num for num in [10..1])

var countdown, num;
countdown = (function() {
  var _results;
  _results = [];
  for (num = 10; num >= 1; num--) {
    _results.push(num);
  }
  return _results;
})();
                           @vagmi | fb.com/vagmi | bit.ly/plusvagmi
CoffeeScript
for filename in list
  do (filename) ->
    fs.readFile filename, (err, contents) ->
      compile filename, contents.toString()



var filename, _fn, _i, _len;
_fn = function(filename) {
   return fs.readFile(filename, function(err, contents)
{
     return compile(filename, contents.toString());
   });
};
for (_i = 0, _len = list.length; _i < _len; _i++) {
   filename = list[_i];
   _fn(filename);
}
                                          @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone.js
               Models

Collections             Views


        Sync       Router

                        @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone - Models
class List extends Backbone.Model

list = new List()
list.set title: “My List”, checklist: true
list.urlRoot = “/api/lists”
list.save()
list.id # gives backend id
list.url # “/api/lists/(backend_id)”



                              @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone - Collections
class Lists extends Backbone.Collection
  model: List
  url: “/api/lists”

lists = new Lists()
lists.fetch()
lists.each (model)->
  #do something with the model



                                 @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone - Views
class ListsView extends Backbone.View
  container: $(“#lists”)
  template: JST[“templates/lists/index”]
  render: =>
    @container.html(@template())
    @delegateEvents()

listsView = new ListsView({collection: lists})
lists.render()



                                  @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone - Views
class ListView extends Backbone.View
  template: JST[“templates/lists/show”]
  initialize: ->
    @render()
  render: =>
    content = @template({list: @model.attributes})
    @options.container.append(content)
    @delegateEvents()

listView = new ListView({model: list})


                                   @vagmi | fb.com/vagmi | bit.ly/plusvagmi
EJS - Templates
tmpl=’<div class="list">
  <h4><%=list.name%></h4>
  <%if(list.checklist){%>
    <p>Score items</p>
  <%}%>
  <ul class="items">
  </ul>
</div>’
fn=EJS.compile(tmpl)
fn({list:@model.attributes})



                               @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone Router
class MyRouter extends Backbone.Router
  routes:
    ""           :    "index" #default route
    "/lists"     :    "showLists"
    "/lists/:id" :    "showList"

  index: =>
    #do something with views

  showLists: =>
    #get the lists

  showList: (id)=>
    list=lists.get(id)
    #fancy stuff
                                       @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Backbone Router

# setup router and history management
myRouter = new MyRouter()
Backbone.history.start()




                                        @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Demo Time




        @vagmi | fb.com/vagmi | bit.ly/plusvagmi
Questions




@vagmi | fb.com/vagmi | bit.ly/plusvagmi

More Related Content

What's hot

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
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesSimon Willison
 
History of jQuery
History of jQueryHistory of jQuery
History of jQueryjeresig
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryRemy Sharp
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using RoomNelson Glauber Leal
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajaxbaygross
 
Mulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitMulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitRebecca Murphey
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuerySudar Muthu
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practicesbrinsknaps
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuerymanugoel2003
 

What's hot (20)

jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
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
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
 
Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011
 
Jquery Fundamentals
Jquery FundamentalsJquery Fundamentals
Jquery Fundamentals
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
Mulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitMulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development Toolkit
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuery
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practices
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 

Similar to Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1

Grails: a quick tutorial (1)
Grails: a quick tutorial (1)Grails: a quick tutorial (1)
Grails: a quick tutorial (1)Davide Rossi
 
Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in RailsBenjamin Vandgrift
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Pythonkwatch
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDmitriy Sobko
 
Statische Websites in Rails 3.1
Statische Websites in Rails 3.1Statische Websites in Rails 3.1
Statische Websites in Rails 3.1RobinBrouwer
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in RailsSeungkyun Nam
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Enginethomas alisi
 
UPenn on Rails pt 2
UPenn on Rails pt 2UPenn on Rails pt 2
UPenn on Rails pt 2Mat Schaffer
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Revath S Kumar
 

Similar to Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1 (20)

Grails: a quick tutorial (1)
Grails: a quick tutorial (1)Grails: a quick tutorial (1)
Grails: a quick tutorial (1)
 
Intro To Sammy
Intro To SammyIntro To Sammy
Intro To Sammy
 
Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in Rails
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Python
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Django quickstart
Django quickstartDjango quickstart
Django quickstart
 
B03-GenomeContent-Intermine
B03-GenomeContent-IntermineB03-GenomeContent-Intermine
B03-GenomeContent-Intermine
 
Statische Websites in Rails 3.1
Statische Websites in Rails 3.1Statische Websites in Rails 3.1
Statische Websites in Rails 3.1
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Engine
 
Django crush course
Django crush course Django crush course
Django crush course
 
UPenn on Rails pt 2
UPenn on Rails pt 2UPenn on Rails pt 2
UPenn on Rails pt 2
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02
 

More from Vagmi Mudumbai

Bitcoin a developer's perspective
Bitcoin a developer's perspectiveBitcoin a developer's perspective
Bitcoin a developer's perspectiveVagmi Mudumbai
 
Crystal - Statically Typed Ruby
Crystal - Statically Typed RubyCrystal - Statically Typed Ruby
Crystal - Statically Typed RubyVagmi Mudumbai
 
Pragmatic Functional Programming in the JS land with Clojurescript and Om
Pragmatic Functional Programming in the JS land with Clojurescript and OmPragmatic Functional Programming in the JS land with Clojurescript and Om
Pragmatic Functional Programming in the JS land with Clojurescript and OmVagmi Mudumbai
 
Building Single Page Apps with React.JS
Building Single Page Apps with React.JSBuilding Single Page Apps with React.JS
Building Single Page Apps with React.JSVagmi Mudumbai
 
JSFoo 2014 - Building beautiful apps with Clojurescript
JSFoo 2014 - Building beautiful apps with ClojurescriptJSFoo 2014 - Building beautiful apps with Clojurescript
JSFoo 2014 - Building beautiful apps with ClojurescriptVagmi Mudumbai
 
Real Time Analytics with Cassandra
Real Time Analytics with CassandraReal Time Analytics with Cassandra
Real Time Analytics with CassandraVagmi Mudumbai
 
Github - Down the Rabbit Hole
Github  - Down the Rabbit HoleGithub  - Down the Rabbit Hole
Github - Down the Rabbit HoleVagmi Mudumbai
 
MongoDB - Introduction
MongoDB - IntroductionMongoDB - Introduction
MongoDB - IntroductionVagmi Mudumbai
 

More from Vagmi Mudumbai (10)

Bitcoin a developer's perspective
Bitcoin a developer's perspectiveBitcoin a developer's perspective
Bitcoin a developer's perspective
 
Purely functional UIs
Purely functional UIsPurely functional UIs
Purely functional UIs
 
Crystal - Statically Typed Ruby
Crystal - Statically Typed RubyCrystal - Statically Typed Ruby
Crystal - Statically Typed Ruby
 
Pragmatic Functional Programming in the JS land with Clojurescript and Om
Pragmatic Functional Programming in the JS land with Clojurescript and OmPragmatic Functional Programming in the JS land with Clojurescript and Om
Pragmatic Functional Programming in the JS land with Clojurescript and Om
 
Building Single Page Apps with React.JS
Building Single Page Apps with React.JSBuilding Single Page Apps with React.JS
Building Single Page Apps with React.JS
 
JSFoo 2014 - Building beautiful apps with Clojurescript
JSFoo 2014 - Building beautiful apps with ClojurescriptJSFoo 2014 - Building beautiful apps with Clojurescript
JSFoo 2014 - Building beautiful apps with Clojurescript
 
Real Time Analytics with Cassandra
Real Time Analytics with CassandraReal Time Analytics with Cassandra
Real Time Analytics with Cassandra
 
Github - Down the Rabbit Hole
Github  - Down the Rabbit HoleGithub  - Down the Rabbit Hole
Github - Down the Rabbit Hole
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
MongoDB - Introduction
MongoDB - IntroductionMongoDB - Introduction
MongoDB - Introduction
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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 ...
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1

  • 1. Building Single Page Web Apps A symphony of Rails, CoffeeScript and Backbone.js Vagmi Mudumbai @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 2. Why Single Page Apps? Fast & Sexy @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 3. Made for each other @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 4. JS and its Good Parts @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 5. CoffeeScript Jeremy Douglas “CoffeeScript” “Javascript” Ashkenas Crockford @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 6. CoffeeScript countdown = (num for num in [10..1]) var countdown, num; countdown = (function() { var _results; _results = []; for (num = 10; num >= 1; num--) { _results.push(num); } return _results; })(); @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 7. CoffeeScript for filename in list do (filename) -> fs.readFile filename, (err, contents) -> compile filename, contents.toString() var filename, _fn, _i, _len; _fn = function(filename) { return fs.readFile(filename, function(err, contents) { return compile(filename, contents.toString()); }); }; for (_i = 0, _len = list.length; _i < _len; _i++) { filename = list[_i]; _fn(filename); } @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 8. Backbone.js Models Collections Views Sync Router @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 9. Backbone - Models class List extends Backbone.Model list = new List() list.set title: “My List”, checklist: true list.urlRoot = “/api/lists” list.save() list.id # gives backend id list.url # “/api/lists/(backend_id)” @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 10. Backbone - Collections class Lists extends Backbone.Collection model: List url: “/api/lists” lists = new Lists() lists.fetch() lists.each (model)-> #do something with the model @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 11. Backbone - Views class ListsView extends Backbone.View container: $(“#lists”) template: JST[“templates/lists/index”] render: => @container.html(@template()) @delegateEvents() listsView = new ListsView({collection: lists}) lists.render() @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 12. Backbone - Views class ListView extends Backbone.View template: JST[“templates/lists/show”] initialize: -> @render() render: => content = @template({list: @model.attributes}) @options.container.append(content) @delegateEvents() listView = new ListView({model: list}) @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 13. EJS - Templates tmpl=’<div class="list"> <h4><%=list.name%></h4> <%if(list.checklist){%> <p>Score items</p> <%}%> <ul class="items"> </ul> </div>’ fn=EJS.compile(tmpl) fn({list:@model.attributes}) @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 14. Backbone Router class MyRouter extends Backbone.Router routes: "" : "index" #default route "/lists" : "showLists" "/lists/:id" : "showList" index: => #do something with views showLists: => #get the lists showList: (id)=> list=lists.get(id) #fancy stuff @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 15. Backbone Router # setup router and history management myRouter = new MyRouter() Backbone.history.start() @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 16. Demo Time @vagmi | fb.com/vagmi | bit.ly/plusvagmi
  • 17. Questions @vagmi | fb.com/vagmi | bit.ly/plusvagmi

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n