On my real estate website’s “properties for rent” page (https://www.dreamspotsrealestate.com/properties-for-rent), I have a dataset of properties connected to a repeater. I have a boolean field for “off-market” properties, so they don’t display on the live page. I set up the filter in the dataset on the page and implemented coding to connect the search input and filters.
Everything works correctly (as in the off-market properties do not display) except for when using the filters.
For example, when I filter for 2 bedrooms under $2000/month, the top result is “2036 S Michigan Avenue” which is checked as “off-market” in the content manager (see screenshot). However, when I search for “Michigan” - only the correct, available properties show up, not 2036 S Michigan.
So this tells me there’s either something wrong with the code or the way I have my data collection setup.
What am I doing wrong and how do I fix this??
See below for my page code and screenshots:
import wixData from 'wix-data';
$w.onReady(function () {
});
//SEARCH FUNCTION
let debounceTimer;
export function searchINPUT_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#searchINPUT').value);
}, 200);
}
let lastFilterTitle;
function filter(title) {
if (lastFilterTitle !== title) {
$w('#dataset1').setFilter(wixData.filter()
.ne('offMarket', true)
.contains('title', title));
lastFilterTitle = title;
}
}
//SORT FILTER
export function button36_click(event) {
$w("#dataset1").setFilter(wixData.filter()
.contains("neighborhoodSort", $w("#neighborhoodDD").value)
.ge("bedrooms", Number($w("#bedroomsDD").value))
.ge("bathrooms", Number($w("#bathroomsDD").value))
.ge("sortRent", Number($w("#priceminDD").value))
.le("sortRent", Number($w("#pricemaxDD").value))
);
}