I’m a first time coder and having trouble applying filtered dropdowns for a real estate site I’m building. I’ve watched several tutorials and scoured these forums to no avail for what feels like days now. Can anyone help me with this? I’m trying to use several dropdowns to filter my repeater (using data from my Properties Dataset) by Location, Property Type, Status (rent/sale), Beds, Baths, and Price (min/max).
Most recently I’ve been following this tutorial called WiX Data Filters by the Dev Team YouTube channel.
This is the code I applied from the tutorial:
import wixData from ‘wix-data’ ;
///////////////////////////////////
export function BTNfilter_click (event, $w) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
$w( “#propertiesDataset” ).setFilter(wixData.filter()
.contains( “neighborhood” , $w( ‘#DDlocations’ ).value)
.contains( “propertieType” , $w( ‘#DDproptype’ ).value)
.contains ( “#status” , $w( ‘#DDstatus’ ).value)
.ge( “bedrooms” , $w( ‘#DDbedrooms’ ).value)
.ge( “bathrooms” , $w( ‘#DDbathrooms’ ).value)
.between( “priceNumber” ,parseFloat($w( ‘#DDpricemin’ .value), parseFloat($w( ‘#DDpricemax’ .value)))
.then((results) => {
console.log( "Dataset is now filtered" );
$w( "#propertiesRepeater" ).data = results.items;
}). **catch** ((err) => {
console.log(err);
});
$w( "#propertiesRepeater" ).expand();
}
I keep receiving the error:
public/pages/u3vui.js/u3vui.js: Unexpected token, expected “,” (21:4)
Hello, looking for a real-estate Filtering-Engine?
Take a look here…
https://www.media-junkie.com/pflegeservice
- Load-Real-Estate-Database-Example, which you will find on page-3 here…
https://www.media-junkie.com/databases
- Set-up a DB(database)-Preset…(for example on SLOT-1/PRESET-1)
3) Save-Settings & close the options.
4) Load your DATABASE.
5) Have a look onto FILTER & FUNCTIONS…
6) Test it and have fun.
7) Read all the given posts, related to this “interactive-example” to learn more about of it’s coding.
Good luck!
I believe that you are missing a couple of parentheses.
You have:
.between("priceNumber",parseFloat($w('#DDpricemin'.value), parseFloat($w('#DDpricemax'.value)))
Should be:
.between("priceNumber",parseFloat($w('#DDpricemin').value), parseFloat($w('#DDpricemax').value)))
Hi Yisrael,
Thanks! That got rid of the error message, but the filter button still isn’t working. Do I need to add something else to get the button to work?
@erinfulmore Did you connect the BTNfilter_click() function to the button? Is the function called when you click on the button? You can use a console.log() statement to make sure. Maybe the function is being called but the filter criteria has no returned results.
@yisrael-wix This is the only console.log () statement I have:
Do I need something else?
.then ((results)=>{
console.log("Dataset is now filtered");
$w("#propertiesRepeater").data=results.items;
}).catch((err);
console.log(err);
});
$w("propertiesRepeater").expand();
}
@erinfulmore Add a console.log() statement to the beginning of the BTNfilter_click() function. This way you can see if the function is being called. You can add any number of console.log() statements that you want in order to inspect what’s going on with your code.
As I asked previously… Did you connect the BTNfilter_click() function to the button?
@yisrael-wix How do I connect it? I thought it was enough to have the event… I’m very new to this, so I appreciate the help…