Chapter 5: Building a Shopping Cart
120
Please note the use of “ 1 records updated ” in the status message. In Chapter 10 , you learn how to
present users with grammatically correct messages. For here, the status message works well enough to
keep you on track.
The beauty of this approach is not just that the interface has been updated by the user, but now the
session has been too, asynchronously. If the user were to leave this page to continue shopping,
the session would be updated as well.
Adding a Delete Function to the Shopping Cart
The original mockup for the Shopping Cart view included a simple way for users to delete an item they
no longer wanted. At this point, if any user sets a product amount to 0, the item gets dropped, but that
isn ’ t very obvious.
So it ’ s time to add a simple delete function. You ’ ll do this in four steps:
- Update the shoppingcart view.
- Add a JavaScript handler.
- Update the Controller.
- Update the Model.
Figure 5 - 5