Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Backbone.js Intro
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Max Lynch
June 19, 2012
Technology
180
3
Share
Backbone.js Intro
A presentation given at MadJS (
http://madjs.com/
) in February 2012
Max Lynch
June 19, 2012
Other Decks in Technology
See All in Technology
終盤で崩壊させないAI駆動開発
j5ik2o
2
2.2k
目的ファーストのハーネス設計 ~ハーネスの変更容易性を高めるための優先順位~
gotalab555
7
1.9k
Standards et agents IA : un tour d’horizon de MCP, A2A, ADK et plus encore
glaforge
0
110
AI駆動1on1〜AIに自分を育ててもらう〜
yoshiakiyasuda
0
120
AIエージェントの権限管理 1: MCPサーバー・ツールの Fine grained access control 編
ren8k
3
480
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
Azure Lifecycle with Copilot CLI
torumakabe
3
990
"SQLは書けません"から始まる データドリブン
kubell_hr
2
460
マルチエージェント × ハーネスエンジニアリング × GitLab Duo Agent Platformで実現する「AIエージェントに仕事をさせる時代へ。」 / 20260421 GitLab Duo Agent Platform
n11sh1
0
140
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
5
14k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
6
18k
クラウドネイティブな開発 ~ 認知負荷に立ち向かうためのコンテナ活用
literalice
0
100
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
180
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.8k
Facilitating Awesome Meetings
lara
57
6.8k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
160
Practical Orchestrator
shlominoach
191
11k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
100
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
Backbone.js Max Lynch h*p://documentcloud.github.com/backbone/
Why Backbone.js • Structure • Cut down on
AJAX “boilerplate” • Backbone.View (chunk of UI) • Backbone.Router (client side URL rouBng)
MVC Framework • Models (your data) • Views
(chunks of UI) • Controller (vague; events originaBng from UI)
Core Features • Backbone.Model (your data) • Backbone.Collection
(groups of models) • Backbone.View (chunk of UI) • Backbone.Router (client side URL rouBng)
Backbone.Model var UserApp = Backbone.Model.extend({ urlRoot: '/api/v1/user/app'
}); Creating: var app = new UserApp(); app.set({‘name’: ‘MadJS’}); app.save(); # POST /api/v1/user/app Loading: var app = new UserApp(); app.id = 54; app.fetch(); # GET /api/v1/user/app/54 Updating: app.set({‘name’: ‘Madison Javascript’}); app.save(); # PUT /api/v1/user/app/54 Deleting: app.destroy(); # DELETE /api/v1/user/app/54
Model JSON {
"name": "MadJS", "created_at": 1329102759, "tree": "..." }
Backbone.Collections var UserApps = Backbone.Collection.extend({ model: UserApp,
url: '/api/v1/user/apps', parse: function(response) { return response.apps; } }); REST API JSON Response: { "apps": [ { "name": "MadJS", "id": 54, "created_at": 1329102759, "tree": "..." } ] } Loading: var app = new UserApps(); app.fetch(); # GET /api/v1/user/apps
Backbone.View var AppView = Backbone.View.extend({ template: _.template($('#app-‐template').html()),
initialize: function() { }, render: function() { $(this.el).html(this.template(this.model.toJSON())); } }); var Dash = Backbone.View.extend({ initialize: function() { //UserApps.bind('add', this.addApp, this); var self = this; var apps = new UserApps(); apps.bind('reset', this.renderApps); apps.fetch(); }, renderApps: function(apps) { apps.each(function(app) { var appView = new AppView({ model: app }); appView.render(); $('#apps').append(appView.el); }); } });
Wrapping it Up <!DOCTYPE html> <html>
<head> <title>Example Dashboard</title> </head> <body> <h1>Your Apps</h1> <ul id="apps"></ul> <script type="text/template" id="app-‐template"> <li> <h4><a href="#"><%= name %></h2></li> </li> </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/ jquery.min.js"></script> <script src="/static/js/ext/underscore.js"></script> <script src="/static/js/ext/backbone.js"></script> <script src="/static/js/app/models.js"></script> <script src="/static/js/dashboard/test.js"></script> </body> </html>