Hi everyone, pleaaaase help I don’t understand the problem
So here is the current flow :
1 / the repeater is populated with a set of data. I have an onClick that runs correctly.
2 / the repeater is now refreshed with a new set of data. The onClick keeps on running correctly.
3 / the repeater is refreshed again with the first set of data. The onClick now runs two times…
If the flow is repeated again, the onClick will run three time etc.
Here is a part of my code :
let currentData
export function refresh_repeater() {
wixData.query("Modeles")
.find()
.then((modeles) => {
$w('#repeater1').data = modeles.items
$w("#repeater1").forEachItem(($item, itemData, index) => {
$item("#image10").src = itemData.src;
$item("#text43").text = itemData.title
$item("#text45").text = itemData.description
});
})
export function repeater1_itemReady($item, itemData, index) {
$item("#image10").onClick((event) => {
console.log("ok")
if ($item('#box3').hidden) {
disable(index)
currentData = itemData
} else {
$item('#box3').hide()
enable()
}
})
}
function enable() {
$w('#repeater1').forEachItem(($item, itemData, index) => {
$item('#box8').hide()
})
}
function disable(indexNumber) {
$w('#repeater1').forEachItem(($item, itemData, index) => {
if (index === indexNumber) {
$item('#box8').hide()
$item("#box3").show()
} else {
$item('#box8').show()
$item("#box3").hide()
}
})
}