Datatable reload issue with ajax on small screen

Datatable reload issue with ajax on small screen

Sikandar_aliSikandar_ali Posts: 2Questions: 1Answers: 0
edited May 2017 in Free community support

I am using data table for my products view and I have Add to cart button at the end of every product to add the product in CART When i click on Add to cart button it adds the product to cart and button changes to View cart I am doing all this by using AJAX and through checking the domain id in cart array $this->cart->contents(); Here is the Ajax

` $.ajax({
type : 'POST',
url : base_url+'home/add',
data : {id:rowId},
beforeSend : function(){
thisElement.html('<i style="font-size:1em;" class="fa fa-spinner fa-pulse fa-3x fa-fw"></i> Add To Cart');
},
success : function(data){

        if(data == 'true'){
            $('.cart').notify("Domain Added To your Cart!" , "success");
            var total_item = $('.total_items').html();
            $('.total_items').html(parseInt(total_item)+1);
            if(windowSize >= 1200){
                thisElement.closest('td').html('<a href="'+base_url+'home/view_cart" class="btn cartBtn">View Cart</a>');
            }else{
                thisElement.closest('td ul li span:last-child').html('<a href="'+base_url+'home/view_cart" class="btn cartBtn">View Cart</a>');
            }
        }else{
            swal("Warning!", "Something Went Wrong!", "warning")
        }
    }
});

});``

...It works fine at Desktop view but when view changes to small screen data table becomes responsive then If I click on Add to cart button first time It changes to View cart but If I click on minus sign of data table responsive icon child td disappear and view cart again changes to Add to cart button. Where is the Problem?? how can It be solved??

Answers

This discussion has been closed.