Skip to content

Commit

Permalink
Fix sort products issue (SallaApp#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
eslamoo authored and abohazza committed Jan 20, 2024
1 parent 4917247 commit c9e2596
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
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 */
13 changes: 6 additions & 7 deletions src/assets/js/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ class Products extends BasePage {
app.element('#product-filter').value = urlParams.get('sort');
}


// 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);
productsList.sortBy = event.currentTarget.value;
app.on('change','#product-filter', async event =>{
window.history.replaceState(null, null, salla.helpers.addParamToUrl('sort',event.currentTarget.value));
app.element('salla-products-list').sortBy=event.currentTarget.value;
await app.element('salla-products-list').reload();
app.element('salla-products-list').setAttribute('filters', `{"sort": "${event.currentTarget.value}"}`)
});

salla.event.once('salla-products-list::products.fetched', res=>{
res.title && (app.element('#page-main-title').innerHTML = res.title);
});
Expand Down

0 comments on commit c9e2596

Please sign in to comment.