The add/remove links do not just point to the same page - they have the query string parameters included to modify the shopping bag contents. Additionally, it is not consequential whether you have a dedicated template to list the shopping bag items; you will still be able to display that list anywhere else.madebym wrote: I know you provided a modified version of the code in this thread, that keeps the user on the same page, but I am using a separate template to show the shopping bag items, so that code doesn't work in my case. It stays on the same page, but the shopping bag page doesn't get populated, of course, beacuse the href attribute is now pointing to the current page we are on.
Moving on to AJAX... In the example code we just need to perform a GET request, not a POST. Ampersands should not be encoded when written in JavaScript. Nevertheless, we do not need to manually hard-code the URL because it is already present in the href attribute of the add link.
- Code: Select all
$(".add-to-design-board").on("click", function(event) {
event.preventDefault();
$.ajax({
url: $(this).attr("href")
}).done(function() {
// Do something
});
});
This is really outside the scope of Couch, so I can't offer more than that.