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

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

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