2

I have different ajax based product carousels in my home page

The problem is ajax add to cart is not working on carousel products after products loaded through ajax

1 Answer 1

3

In your ajax success function use this code:

jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

It will reinitialize add to cart

jQuery.ajax({
    url: "/request",
    type: "POST",
    success: function (res) {
        //Other code here

        jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();
    }
});
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.