Ajax add to cart is not working after products loaded by other ajax request
-
17-02-2021 - |
Pregunta
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
Solución
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();
}
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange