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


In your ajax success function use this code:

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

It will reinitialize add to cart

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

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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