[英]After Append Product` add to cart` is not working
I have div as follows 我有如下的div
<li> <a data-id="'.$row_p[0].'" data-name="'.$row_p[3].'" data-summary="'.$row_p[3].'" data-price="'.$row_p[6].'" data-quantity="1" data-image="'.$row_p[12].'" class="add-cart"> <span class="icon flaticon-shopping66 "></span> </a> </li>
On add-cart
click Following Function calls( it is an ready plugin that is easily available to show an cart. ) 在
add-cart
单击“跟随函数”调用( 这是一个易于使用的插件,可以轻松地显示购物车。 )
$('.add-cart').myCart({ classCartIcon: 'my-cart-icon', classCartBadge: 'my-cart-badge', classProductQuantity: 'my-product-quantity', classProductRemove: 'my-product-remove', classCheckoutCart: 'my-cart-checkout', affixCartIcon: true, showCheckoutModal: true, clickOnAddToCart: function($addTocart){ goToCartIcon($addTocart); }, clickOnCartIcon: function($cartIcon, products, totalPrice, totalQuantity) { console.log("cart icon clicked", $cartIcon, products, totalPrice, totalQuantity); }, checkoutCart: function(products, totalPrice, totalQuantity) { console.log("checking out", products, totalPrice, totalQuantity); }, getDiscountPrice: function(products, totalPrice, totalQuantity) { console.log("calculating discount", products, totalPrice, totalQuantity); return totalPrice; } }); But Now the problem is i am using load more jquery Which Load Data On Scroll `$(window).scroll(function()..` So on scroll i am showing Div As Following $.ajax({ url: 'ajax-load-subcat.php', type: 'post', data: {row:row,idsubcat:idsubcat}, beforeSend: function() { $("#dataload").show(); }, success: function(response){ $(".post:last").after(response).show().fadeIn("fast"); $("#dataload").hide(); } });
So After Dive is appended the add-cart
function is also closed. 因此,在附加了Dive之后,
add-cart
功能也将关闭。 means it isn't responding. 表示它没有响应。 so how can i re-start my cart when i scroll and data is loaded.
因此,当我滚动并加载数据时,如何重新启动购物车。
I have searched a lot. 我搜了很多。 but they didn't solves my problem.
但是他们没有解决我的问题。 thank you.
谢谢。
Try to initialize add-class/add-cart function again on success of ajax 尝试在ajax成功时再次初始化add-class / add-cart函数
$.ajax({
url: 'ajax-load-subcat.php',
type: 'post',
data: {row:row,idsubcat:idsubcat},
beforeSend: function() {
$("#dataload").show();
},
success: function(response){
$(".post:last").after(response).show().fadeIn("fast");
$("#dataload").hide();
//Re-intiallize Function
$('.add-cart').myCart({
....
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.