Hi,
I was wondering if someone would be able to point me in the direction of why I can’t get the below code to filter with the dropdowns?
I have been trying to improve the sites speed and responsiveness and have been trying to use the backend for multiple queries.
Note: pageTitle is the field key for the grades.
Back end
import wixData from 'wix-data';
import wixUsersBackend from 'wix-users-backend';
export function getSearch(field, test) {
let query = wixData.query("Courses");
if(test.length > 0) {
query = query.contains(field, test);
}
return query.find();
}
Front end
import {getSearch} from 'backend/utilitiesModule';
export function searchButton_click(event) {
//$w('#regionDropdown').value = "all";
let categoryValue = $w('#dynamicDataset').getCurrentItem().title;
let gradeValue = $w('#gradeDropdown').value;
let regionValue = $w('#regionDropdown').value;
console.log(regionValue)
console.log(gradeValue)
console.log(categoryValue)
getSearch("coursesCategory", categoryValue && "pageTitle", gradeValue ).then(function (resp) {
let items = resp.items;
let courses = [];
items.forEach(function (item) {
let course = { "coursesCategory": item.coursesCategory, "rating": item.rating, "_id": item._id, "title": item.title, "image": item.image, "duration": item.duration, "individaulPrice": item.individaulPrice, "lightbox": item.lightbox, "prices": item.prices, "description": item.description, "count": item.count };
courses.push(course);
});
$w('#repeater1').scrollTo();
$w("#repeater1").data = [];
$w("#repeater1").data = courses;
});
$w("#gradeDropdownTwo").value = $w('#gradeDropdown').value;
$w("#regionDropdownTwo").value = $w('#regionDropdown').value;
}
I have working code
getSearch("pageTitle", gradeValue ).then
but on the dynamic page all of the grades for all trips show not just what is relevant to the current page i.e. rock climbing it would show every trip from hiking, holidays, canoeing etc
so I tried this line but it doesn’t seem to work but no errors.
getSearch("coursesCategory", categoryValue && "pageTitle", gradeValue ).then
In the end, I’m looking to combine two dropdowns, grade and region and the relevant trip category to display the appropriate trips on the dynamic page.
Thank you!