Chapter 6. Building the RocknRollCall Prototype: Controllers, Views, Data Binding, and Events
We’ve figured out templates. We’ve figured out routers and routes. We’ve figured out models. What’s left?
Well, we need a place to keep track of moment-to-moment state data: the kind of stuff you absolutely need to know right now but you probably don’t need to write to a database. This is the kind of state that you expect to reset when you leave and come back to a site. We also need a place for more complicated rendering logic. We need a way to coordinate this fancy renderer and our moment-to-moment state data manager.
For the transient state data, we need controllers. We need views for the extended rendering control. We need events to connect controllers and views, and, finally, we need data binding to keep our data in-sync across all these pieces.
When we’ve got all these in place, we’ll have a working prototype. Let’s do it!
Controllers
Yes, you’ve gotten all the way to Chapter 6 in a book about an MVC framework without really talking about views or controllers (or really-real models, for that matter). Don’t worry. You’ll get your money’s worth.
In Ember, controllers have these four most important jobs (among others):
-
Manipulate the data within the application’s models
-
Store transient data, whether standalone or made up of data retrieved from models
-
Listen to events dispatched by and dispatch events intended for other controllers, views, and templates
-
Instigate the transition ...
Get Building Web Apps with Ember.js now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.