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:
-
Attaching a control to an element on the page
-
Listening to UI events
-
Using the data() function to retrieve a model from the page
-
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 ...
Get Seven Web Frameworks in Seven Weeks 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.