Skip to content

Commit

Permalink
Fix products list sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
eslamoo committed Sep 27, 2023
1 parent 349baa3 commit f4dd81a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/home.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/landing.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion public/product.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/product.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
8 changes: 0 additions & 8 deletions src/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class App extends AppHelpers {
this.initiateDropdowns();
this.initiateModals();
this.initiateCollapse();
this.reloadPageAfterFiltering();
initTootTip();
this.loadModalImgOnclick();

Expand All @@ -31,13 +30,6 @@ class App extends AppHelpers {
this.log('Theme Loaded 🎉');
}

// reload page after filtering
reloadPageAfterFiltering(){
document.querySelector('#product-filter')?.addEventListener('change',()=>{
location.reload();
})
}

log(message) {
salla.log(`ThemeApp(Raed)::${message}`);
return this;
Expand Down
8 changes: 4 additions & 4 deletions src/assets/js/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class Products extends BasePage {


// Sort Products
app.on('change', '#product-filter', event => {
let url = new URL(window.location.href);
url.searchParams.set('sort', event.currentTarget.value);
window.history.pushState({}, '', url);
app.on('change', '#product-filter', async event => {
window.history.replaceState(null, null, salla.helpers.addParamToUrl('sort', event.currentTarget.value));
productsList.sortBy = event.currentTarget.value;
await productsList.reload();
productsList.setAttribute('filters', `{"sort": "${event.currentTarget.value}"}`)
});

salla.event.once('salla-products-list::products.fetched', res=>{
Expand Down

0 comments on commit f4dd81a

Please sign in to comment.