Skip to content

Commit

Permalink
awesto#859 Added remove existed params before Ajax request
Browse files Browse the repository at this point in the history
  • Loading branch information
execut committed Jun 23, 2021
1 parent 8cb5cba commit 6ad3f43
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions shop/static/shop/js/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ djangoShopModule.controller('CatalogListController', ['$log', '$scope', '$http',
this.loadProducts = function(config) {
if ($scope.isLoading || fetchURL === null)
return;

config = this.deleteExistedSearchParams(config);
$scope.isLoading = true;
$http.get(fetchURL, config).then(function(response) {
fetchURL = response.data.next;
Expand All @@ -136,6 +138,17 @@ djangoShopModule.controller('CatalogListController', ['$log', '$scope', '$http',
});
};

this.deleteExistedSearchParams = function (config) {
if (typeof URLSearchParams !== 'undefined') {
let searchParams = new URLSearchParams(fetchURL.substring(fetchURL.indexOf('?')));
for (let key in config.params) {
if (searchParams.has(key)) {
delete config.params[key];
}
}
}
};

this.resetProductsList = function() {
fetchURL = djangoShop.getLocationPath();
$scope.catalog.products = [];
Expand Down

0 comments on commit 6ad3f43

Please sign in to comment.