September 2018
Intermediate to advanced
398 pages
9h 43m
English
The action to remove a product from the cart is triggered when the X button related to a cart entry is clicked. This is implemented in the removeFromCart() method, located in the CartLine class. This is similar to the method we used in the previous section. The code is as follows:
private def removeFromCart() = () => UIManager.deleteProduct(product)
We delegate the action to UIManager, and the implementation is as follows:
def deleteProduct(product: Product): JQueryDeferred = { def onDone = () => { val cartContent = $(s"#cart-${product.code}-row") cartContent.remove() println(s"Product ${product.code} removed from the cart") } deletefromCart(product.code, onDone)}
This time, we call the deleteFromCart method ...
Read now
Unlock full access