Finally, we have to call the watch() method of the controller. This keeps an eye on the
form and checks when it is submitted. Add the following line to the end of the scripts.js
Open up list.htm in your browser and have a go at adding some items to the list. It should
look a little like the screenshot shown in Figure 15.2 .
Figure 15.2. An MVC to-do list
This is just a small and simple example of the MVC pattern to give an idea of how it
works. In reality the model would contain many more properties and methods; the con-
troller would also contain more methods for editing and deleting instances of the model.
There's also likely to be more views to display the different states of the model, and there
would need to be more robust code used in order for the controller to monitor the changes
Search WWH ::