You are on page 1of 14

Getting Start

backbone.js
SonicGarden Inc.
Masahiro Nishimi

backbone.js
DocumentCloud
JavaScriptMVC

(DocumentCloud http://www.documentcloud.org/)
37SignalsBasecamp Mobile
Foursquare

backbone.js

jQuery
JavaScript
MVC

History APISingle Page


Application
pushState
URL

knockout.js
backbone.js

Silverlight
Model-View-View Model(MVVM)


http://learn.knockoutjs.com/

knockout.js

backbone.jsRails
Rails
37Signalsbackbone.js
rails-backbonegem


backbone.js
o Model (M)
RailsModelIDURL
o Collection (M)
ModelURL
o Router (C)
URL
o Template (V)
View(JST)
o View (V, C)
View
ViewController

Architecture
backbone.js with Rails
Rails

View

backbone.js

Browser

Render

URL

View

Router

Model

Controller

RESTful JSON

Model

Scaffold Strategy
Collection (/foo)

/foo (foo#index)
/foo/new (foo#new)

Model(/foo/1)

Model(/foo/2)

Model(/foo/3)

Model(/foo/4)

/foo/1 (foo#show)
/foo/1 (foo#edit)
/foo/1 (foo#destroy)

backbone.js
with Rails
rails-backbone(>= Rails3.1)
(https://github.com/codebrew/backbone-rails)
rails-backbonescaffold

rails g backbone:install
rails g backbone:scaffold Hoge foo:string bar:string
# /app/assets/javascriptsRouter, Views, Templates, Model
#

coffee script
jscs

Templatehaml

ver 0.0.1gem
JSTHAMLJS
JSTEJS
rails-backbone

JSTHAMLJS
node.jshamljssprockets
gem
Rails)

JSTEJSHAML

Sample Code Tour


vimrcbest vimrc
backbone.js with Rails

http://best-vimrc.heroku.com/
https://github.com/mahm/best-vimrc

best vimrc

o Twittersign invimrc

o vimrc2

o URLGET


o has_manybackbone.js

o URLbackbone.js

o (ref. http://vimeo.com/31767882)

Summary
backbone.js + RailsWeb

Templatehaml
Contribute
backbone.js

http://documentcloud.github.com/backbone/docs/backbone.html

Reference
backbone.js
o http://documentcloud.github.com/backbone/

Tutorials
o https://github.com/documentcloud/backbone/wiki/Tutorials%2C-blogposts-and-example-sites

jQuery Mobile
backbone.js
o http://lab.dwango.jp/articles/jquery-mobile-app-development/2-addmvc-with-backbone.html

codebrew/backbone-rails
o https://github.com/codebrew/backbone-rails

backbone-rails vimeo
o http://vimeo.com/30705694