Backbone.js – an introduction
-
Upload
bobbyroe -
Category
Technology
-
view
683 -
download
0
description
Transcript of Backbone.js – an introduction
Javascript Developer at The New York Times Companydeveloping Ricochet
Bobby Roe
Backbone.jsAn Introduction
What is it?
Backbone.js is the model & view layerfor your javascript app
Why?
* The DOM isn't the source of truth in your app.
jQuery is good.
Storing state in the DOM is bad.
* A single source of data for the UI to render.
not just a web siteto create a web app
Here are a whole bunch of real world projects
Core Features
Models - attributes
Collections - filter, transform, manage your models
Views - UI events - data events (on) * acts as controllers
Other Features... not covered here --
* Routers * the Sync function
Demo -- Mastermind
?
?
Collection: Turn_collection
View methods
initialize
render
template
Chrome console demo
another View: Game_view
Game_view: initialize
Game_view: render
A Couple of Potholes to Avoid
Do: Fully re-render your views (from templates).
Don't: show / hide bits of UI / get & set HTML attributes.
Do: Look at a lot of examples & keep your functions simple & small.
Don't write intimidating, epic code.
Summary
Backbone is the model & view layer for your app * one source of data * optimized rendering * simple core features that rock