Reputation: 1
https://russian-dima.wixsite.com/wixworld/nedvizhimost-iiii this site is exactly I'm trying to create. I coded all dropdowns but price filter code doesn't work. I don't know why!
import wixData from 'wix-data';
export function button14_click(event) {
$w.onReady(function () {
let min = Number($w("#input1").value)
let max = Number($w("#input2").value)
$w("#dataset1").setFilter(wixData.filter().between("fiyat", min, max))
.then((results) => {
console.log("Dataset is now filtered");
$w('#propertyList').data = results.items;
});
})
Upvotes: 0
Views: 291
Reputation: 1
The $w.onReady
method should be at the root of the page, it is the method that runs on page load.
You could create the button onClick inside of the $w.onReady
method like this:
import wixData from 'wix-data'
$w.onReady(async function () {
//Await the dataset to be ready
await $w('#dataset1').onReadyAsync()
//Click event for the button
$w('#button14').onClick(async function () {
let min = Number($w('#input1').value)
let max = Number($w('#input2').value)
await $w('#dataset1').setFilter(wixData.filter().between('fiyat', min, max))
//Refresh the dataset
await $w('#dataset1').refresh()
})
})
Upvotes: 0