Stuff • POJO • Prototype of all Backbone objects • Can emit events • Can listen to other objects for events to trigger callbacks Remember: state is maintained, all object instances are just hanging out in memory in your browser window
Stuff • POJO • Manages specific parts of DOM • Has attached models or collections • render() HTML to modify the DOM (with the help of a Template) • Listens for changes on attached models/collections • Can have childviews (it’s childviews all the way down)
Stuff • POJO • Router: defines callbacks based on URL (instantiate models/collections and inject into a new high-level view) • History: manages global state • Application: Tie it all together at the highest level to be exposed to the browser via <script>
= new User id: userId userView = new UserView el: '#page' model: user user.fetch() Bad 1. Initialize 2. Instantiate 3. Trigger Side Effects class UserView extends Backbone.View initialize: (userId) -> @model = new User id: userId @model.fetch()