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 ...