Professional CodeIgniter, Thomas Myer

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:


1.


Update the shoppingcart view.


2.


Add a JavaScript handler.


3.
Update the Controller.


4.
Update the Model.

Figure 5 - 5
c05.indd 120
c05.indd 120
6/10/08 5:35:19 PM
6/10/08 5:35:19 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.