O'Reilly logo

Seven Web Frameworks in Seven Weeks by Frederic Daoud, Jack Moffitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Day 2: Creating Controllers

We now have models and views. When models change, views automatically update. Now how about combining them into components? Also, when the user presses the Edit or Delete button in the list of bookmarks, we want to edit or delete the corresponding bookmark. We need a place for that event-handling code. This is where controllers, or just controls as they are called in CanJS, come into the picture. Today we discuss four vital aspects of can.Control:

  1. Attaching a control to an element on the page

  2. Listening to UI events

  3. Using the data() function to retrieve a model from the page

  4. Using an observe to communicate between controllers

In doing so, we’ll create two controls: one for the bookmark list and one for the form that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required