I’m helping a family member with their website, and I keep encountering this error while trying to filter a repeater. I’ve tried figuring out the problem for a while, but keep coming up empty.
I’m pretty new to this, so it has me stumped.
import wixData from 'wix-data';
$w.onReady (function () {
}) ;
export function stateDropdown_change(event) {
let searchState = $w("#stateDropdown").value;
$w("#artistData").setFilter(wixData.filter().contains("state", searchState));
}
export function storeDropdown_change(event) {
let filterService = $w("#serviceDropdown").value;
$w("#artistData").onReady( () => {
if (filterstore === "Hair Stylist") {
$w("#artistData").setFilter(wixData.filter().eq("hairStylist", true));
}
if (filterstore === "Hair Extension Technician") {
$w("#artistData").setFilter(wixData.filter().eq("hairExtensionTech", true));
}
if (filterstore === "Nail Technician") {
$w("#artistData").setFilter(wixData.filter().eq("nailTech", true));
}
if (filterstore === "Makeup Artist") {
$w("#artistData").setFilter(wixData.filter().eq("makeupArtist", true));
}
if (filterstore === "Eyelash Technician") {
$w("#artistData").setFilter(wixData.filter().eq("eyelashTech", true));
}
if (filterstore === "Hair Removal Technician") {
$w("#artistData").setFilter(wixData.filter().eq("hairRemovalTech", true));
}
if (filterstore === "Bridal Specialist") {
$w("#artistData").setFilter(wixData.filter().eq("bridalSpecialist", true));
}
}
}
)}
Hi, tammy .
If you replace the last three/3 lines of storeDropdown_change function:
}
}
)}
with the following two/lines:
}
)}
does that resolve the error for you?
Unfortunately, after replacing those lines, I received the error ‘filterstore’ is not defined.
OK, I used my tried-and-true technique of copying the code for that function into NotePad++ and reformatting the code (as well as matching parentheses and braces).
Please replace the entire storeDropdown_change() function with the following code:
export function storeDropdown_change(event) {
let filterService = $w("#serviceDropdown").value;
$w("#artistData")
.onReady( () => {
if (filterstore === "Hair Stylist") {
$w("#artistData").setFilter(wixData.filter().eq("hairStylist", true));
}
if (filterstore === "Hair Extension Technician") {
$w("#artistData").setFilter(wixData.filter().eq("hairExtensionTech", true));
}
if (filterstore === "Nail Technician") {
$w("#artistData").setFilter(wixData.filter().eq("nailTech", true));
}
if (filterstore === "Makeup Artist") {
$w("#artistData").setFilter(wixData.filter().eq("makeupArtist", true));
}
if (filterstore === "Eyelash Technician") {
$w("#artistData").setFilter(wixData.filter().eq("eyelashTech", true));
}
if (filterstore === "Hair Removal Technician") {
$w("#artistData").setFilter(wixData.filter().eq("hairRemovalTech", true));
}
if (filterstore === "Bridal Specialist") {
$w("#artistData").setFilter(wixData.filter().eq("bridalSpecialist", true));
}
}
)
}
The code can be further simplified to the following:
export function storeDropdown_change(event) {
let filterService = $w("#serviceDropdown").value;
$w("#artistData")
.onReady( () => {
var propertyName;
if (filterstore === "Hair Stylist") {
propertyName = "hairStylist";
}
if (filterstore === "Hair Extension Technician") {
propertyName = "hairExtensionTech";
}
if (filterstore === "Nail Technician") {
propertyName = "nailTech";
}
if (filterstore === "Makeup Artist") {
propertyName = "makeupArtist";
}
if (filterstore === "Eyelash Technician") {
propertyName = "eyelashTech";
}
if (filterstore === "Hair Removal Technician") {
propertyName = "hairRemovalTech";
}
if (filterstore === "Bridal Specialist") {
propertyName = "bridalSpecialist";
}
$w("#artistData").setFilter(wixData.filter().eq(propertyName, true));
}
)
}
which can then be even further simplified to the following:
export function storeDropdown_change(event) {
let filterService = $w("#serviceDropdown").value;
$w("#artistData")
.onReady( () => {
var propertyName;
switch (filterstore) {
case: 'Hair Stylist':
propertyName = 'hairStylist';
break;
case: 'Hair Extension Technician':
propertyName = 'hairExtensionTech';
break;
case: 'Nail Technician':
propertyName = 'nailTech';
break;
case: 'Makeup Artist':
propertyName = 'makeupArtist';
break;
case: 'Eyelash Technician':
propertyName = 'eyelashTech';
break;
case: 'Hair Removal Technician':
propertyName = 'hairRemovalTech';
break;
case: 'Bridal Specialist':
propertyName = 'bridalSpecialist';
break;
}
$w("#artistData").setFilter(wixData.filter().eq(propertyName, true));
}
)
}
In response to the " ‘filterstore’ is not defined." error, you’re getting, does replacing “filterstore” with “filterService” resolve that issue for you?
Thank you for the help! The filtering on the site is now working!
Also, good call on the filterstore/filterService screwup. I somehow missed that.
You’re welcome!
Remember:
- the number of left parentheses must equal the number of right parentheses
- the number of left curly braces must equal the number of right curly braces
That one thing should save you some frustration.
// Code type nouveau projet défilement des images
//NU_OPE
// Lancement Diaporama + Fermeture
export function PHB37stb_mouseIn(event) {
$w(“#37PHBtx”).show();
}
export function PHB37stb_mouseOut(event) {
$w(‘#PHB37stb’).changeState(“37PHBststart”);($w(‘#84VEUstb’).changeState(“84VEUststart”));
}
// Défilement images
$w.onReady(function () {
$w(“#37PHBimstart”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst01”);
} );
$w.onReady(function () {
$w(“#37PHBim01”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst02”);
} );
$w.onReady(function () {
$w(“#37PHBim02”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst03”);
} );
$w.onReady(function () {
$w(“#37PHBim03”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst04”);
} );
$w.onReady(function () {
$w(“#37PHBim04”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst05”);
} );
$w.onReady(function () {
$w(“#37PHBim05”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst06”);
} );
$w.onReady(function () {
$w(“#37PHBim06”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst07”);
} );
$w.onReady(function () {
$w(“#37PHBim07”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst08”);
} );
$w.onReady(function () {
$w(“#37PHBim08”).onClick(() => {
$w(‘#PHB37stb’).changeState(“37PHBst01”);
} );