Hello,
I followed the tutorial on adding dropdown filtering to a database. I had to alter the code for a repeater instead of a table. The load options distinctly function isn’t working. Line 69 has a parsing error. How do I fix this?
Tutorial I followed: https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality
Thanks for any help in advance!
Here is my code:
import wixData from "wix-data";
export function searchBox_keyPress(event) {
wixData.query("Listings")
// Query the collection for any items whose "Name" field contains
// the value the user entered in the input element
.contains("street", $w("#searchBox").value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w("#repeater1").data = res.items;
});
}
export function dropdown1_change(event) {
wixData.query("Listings")
// Query the collection for any items whose "Name" field contains
// the value the user selected in the dropdown
.contains("city", $w("#dropdown1").value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w("#repeater1").data = res.items;
});
}
function loadOptions() {
// Run a query that returns distinct items in the collection
wixData.query("Listings")
// Set the course as the field that must be distinct
.distinct("city")
.then(results => {
// Call another function to reformat the distinct items
// the way the dropdown element expects
let distinctList = buildOptions(results.items);
// Use `unshift()` to add another dropdown option at
// the beginning of the array, in the correct format
distinctList.unshift({ "value": '', "label": 'All Cities' });
// Set the options of the dropdown
$w("#dropdown1").options = distinctList;
});
}
function buildOptions(dropdownItems) {
return items.map(currentItem => {
return {
"label": "currentItem",
"value": "currentItem"
};
});
}
$w.onReady(() => {
loadOptions();
$w("#repeater1").data = [{
... //This is the line I'm getting error
...
...
}];
});