Hi everyone, I have a repeater and I’m filtering products based on a boolean. Everything filters fine on load, but after the user searches and then deletes the other products show up in the repeater. Here’s the code:
$w.onReady(function() {
$w("#amLogo, #crLogo, #ppLogo").hide();
const STATE_BOX = $w('#StateBox1');
/**
* Changes a state on multi-state box when a button is clicked
* @param {number} buttonId - the ID of the button.
* @param {string} state - state of the StateBox to switch to.
*/
// function changeContent(buttonId, state){
// $w(`#button${buttonId}`).onClick( (event) => {
// STATE_BOX.changeState(state)
// });
// }
// changeContent(36, 'allBooks2')
// changeContent(37, 'anthologies');
// changeContent(39, 'editorsChoice');
const buttons = $w('#group21').children;
const activeColor = 'rgb(26, 25, 25)';
const disableColor = 'rgb(118,116,116)';
const firstBtn = buttons[0];
firstBtn.style.color = activeColor;
buttons.forEach((btn, index) => {
btn.style.color = disableColor;
if(index === 0) {btn.style.color = activeColor}
btn.onClick((event) => {
removeActiveState();
event.target.style.color = activeColor;
})
})
function removeActiveState() {
buttons.forEach(btn => {
btn.style.color = disableColor;
})
}
$w("#repeater1").onItemReady( ($item, itemData, index) => {
let theItem = itemData.description;
var shortDescription = theItem.substr(0,300
);
$item("#text262").text = shortDescription + "...";
});
$w("#anthologiesRepeater").onItemReady( ($item, itemData, index) => {
let theItem = itemData.description;
var shortDescription = theItem.substr(0,450);
$item("#text262").text = shortDescription + "...";
});
$w("#editorsChoicerepeater").onItemReady( ($item, itemData, index) => {
let theItem = itemData.description;
var shortDescription = theItem.substr(0,450);
$item("#text262").text = shortDescription + "...";
});
$w("#repeaterFAQ1").onItemReady(($item) => {
$item('#Expand1').onClick(() => {
$item('#AnswerBox1').expand()
$item('#Expand1').hide()
$item('#collapse1').show()
})
$item('#collapse1').onClick(() => {
$item('#AnswerBox1').collapse()
$item('#Expand1').show()
$item('#collapse1').hide()
})
})
})
import wixData from "wix-data";
let debouncetimer;
export function input1_keyPress(event) {
if (debouncetimer) {
clearTimeout(debouncetimer);
debouncetimer = undefined;
}
debouncetimer = setTimeout(() => {
let filterValue = $w('#input1').value;
filter(filterValue);
console.log(filterValue);
}, 200);
}
let lastValue;
function filter(value) {
if (lastValue !== value) {
$w('#dataset6').setFilter(wixData.filter()
.eq('isCaezikScienceFictionAndFantasy', true)
.contains('bookTitle', value,)
.or(
wixData.filter()
.contains('authorNamesFormatted', value,)
))
.then( () => {
console.log("Dataset is now filtered");
} )
.catch( (err) => {
console.log(err);
} )
}
lastValue = value;
}