我有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>
在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();
}
});
因此,在追加潜水后,add-cart
功能也会关闭。意味着它没有响应。那么当我滚动和加载数据时,如何重新启动我的购物车。
我搜索了很多。但他们没有解决我的问题。谢谢。
答案 0 :(得分:0)
尝试在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({
....
});
}
});