1. Add /cart/addAndCheckout method to CartController that adds the product to cart and redirect to /checkout/expressCheckout
2. Add /checkout/expressCheckout to CheckoutController that returns /checkout/expressCheckout view module
3. Add expressCheckoutLayout that includes /cart/cart as header
4. Add entry to layout map in application-servlet.xml such that /checkout/expressCheckout view using expressCheckoutLayout.
Everything works perfectly except for the jQuery/Ajax functionality in cartOperations.js view. I added some debug alert and found everything works fine except that the last line to update the cart's html doesn't work. For instance, remove an item from cart:
Code: Select all
// Intercept remove from cart operations and perform them via AJAX instead
// This will trigger on any link with class "remove_from_cart"
$('body').on('click', 'a.remove_from_cart', function() {
alert('remove_from_cart');
var link = this;
BLC.ajax({url: $(link).attr('href'),
type: "GET"
}, function(data, extraData) {
updateHeaderCartItemsCount(extraData.cartItemCount);
showAddToCartButton(extraData.productId, 'cart');
alert(data);
$('.fancybox-inner').html(data);
}
);
return false;
});
Further experiment, I found this jQuery/Ajax only works in popup. If I navigate to /cart in the browser directly, it won't work either. I'm new to jQuery, can someone give me a hint? Is this the problem of selector qualifier or sort?
Thank you in advance!
-Charlie