I created this view in basket/views.py:
class BasketMiniViewAjax(TemplateView):
template_name = "partials/mini_basket_ajax.html"
def get_context_data(self, **kwargs):
context = super(BasketMiniViewAjax, self).get_context_data(**kwargs)
return context
this js function in my included js file:
function ajax_update_basket_mini(url_update_basket_mini){
$.ajax({
type: "GET",
url: url_update_basket_mini,
dataType: "html",
cache: false,
success: function(data) {
if (data){
//alert(data);
$(".basket-mini").html(data);
return true;
}
}
});
}
added url in my basket/app.py:
basket_mini_ajax_view = views.BasketMiniViewAjax
... and
url(r'^basket_mini_ajax/$', self.basket_mini_ajax_view.as_view(), name='ajax-basket-mini'),
calling the update to happen after basket qty is changed:
ajax_update_basket_mini("{% url 'basket:ajax-basket-mini' %}");