How to do "delete item" AJAX

if we add an item to the shopping cart, the AJAX is easy:

the View adds an item to the cart, and also set the “current_item_added”
and then just let the view (RJS) update the whole cart content, and then
blink the current_item_added, and that’s it.

but what about now it is deleting an item, and it is the last item in
the cart, so how do you let the Controller find that item, and let the
View blink it, and then come back to the Controller to delete that item,
and then go to the View again to update the new cart?

I can think of letting the Controller dup the original cart first as
old_cart(need deep copy?), and then passing the following to the View:

  1. current_item_deleted
  2. old_cart
  3. new_cart

and then let the RJS blink the current_item_deleted with the old_cart,
and then, display the cart using new_cart.

is this not proper, or is there a proper MVC way?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs