I would like to change the container background on click inside a repeater. After looking at the documentation here is my code
$userCards.onClick((event) => { const data = $userCardRepeater.data; let clickedItemData = data.filter(item => item._id === event.context.itemId)[0]; let $item = $w.at(event.context);
// If the data is not selected change the bg to red otherwise green if (clickedItemData.selected !== true ) {
clickedItemData.selected = true ;
$item(‘#userCard’).style.backgroundColor = ‘red’;
} else {
clickedItemData.selected = false ;
$item(‘#userCard’).style.backgroundColor = ‘green’;
}
});
The error is that “style” is undefined on $item(“#userCard”) which is a valid Element.
I ended up doing a little testing of a box element in a repeater and found it to be clumsier than I expected, for the lack of a better term. Apparently, the only thing that they have to offer in a repeater is the potential to be styled. Maybe, someone else has made them functional for this purpose?
It works but -but - but - change All BGImages in all Items of current Reprater.
I desperately trying found how specify Repeater containers Items in Current Repeater - and cannot
I believe that they are have some instance names, may be Array With Numbers like 0.1.2…
If You know - I will be very appreciate
May be somesing
let myclickedcontainer = $w.container(#mycontainer).clikedone - something like this… I try to guess - but currently unhappy, unsuccessful
@plomteuxquentin Dear Quentin - I spoke about Item in Repiter where No Style and Background color As You disscus here before - - only baclground Images… But when I change it - It changed in all Repeatr Items… I trying to find
ID
for each container after page opened - current moment. I hope they have some ID
And change BGImage by this ID