Skip to content

Commit

Permalink
have sort preferences trigger a search
Browse files Browse the repository at this point in the history
  • Loading branch information
sammdu committed Dec 12, 2021
1 parent 3a6dbbc commit c5ad199
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function onPageLoad() {

// configure default sort key
let sortByURL = fetchQueryParamByKey('sort_by');
if (sortByURL === null || sortByURL === 'price') {
setSortByFromElement();
if (sortByURL === null) {
setPairInQuery('sort_by', 'price');
}
else {
// change the input element selected value to reflect URL selection
Expand Down Expand Up @@ -164,6 +164,8 @@ function toggleSortOrder() {
// configure the search params to set ascending search order to false
setPairInQuery('sort_asc', 'false');
}
// trigger a search
submitSearch();
}

/*
Expand All @@ -175,6 +177,8 @@ function setSortByFromElement() {
const sortByVal = sortBySelect.options[sortBySelect.selectedIndex].value;
// configure the search params to set desired sort-by value
setPairInQuery('sort_by', sortByVal);
// trigger a search
submitSearch();
}

/*
Expand Down

0 comments on commit c5ad199

Please sign in to comment.