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

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

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