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
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
?
?
View methods
initialize
render
template
Chrome console demo
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