Hi
I have a repeater showing 6 images.
I need to run some code for each record to determine whether to show this image or a different one, but I can’t see how to edit the repeater. Any help?
Thanks
Tom
Hi
I have a repeater showing 6 images.
Thanks
Tom
Can you show the database structure too?
Sorry, I should re-word that
I’m not asking for somebody to write this for me, just tell me how I can edit the repeater.
https://www.wix.com/velo/reference/$w/repeater/foreachitem
This helps you to ‘access’ the stuff INSIDE repeater
$w("#myRepeater").forEachItem( ($item, itemData, index) => {
let repeatedElement = $item("#repeatedElement");
let nonRepeatedElement = $w("#nonRepeatedElement");
let itemDataValue = itemData.someProperty;
let isEvenItem = index % 2 === 0;
} );
Edit the code inside the {}
Maybe something like:
if (itemData.hide === true) {
$w('#image).hide()
} else {$w('#image).show()}
Thanks ![]()
I’ve pasted in the code from the Velo page you pasted (thank you). I’ve changed a couple of things for my code. I’m not sure what I should put in inplace of ($item, itemData, index).
Could you help? Some of the entries will have the same session(“userID”) as multiple entries in the db. Can you point me in the right direction?
The code is:
$w( “#repeater1” ).forEachItem( ($item, itemData, index) => {
let repeatedElement = $item( “image1” );
let itemDataValue = itemData.someProperty;
let isEvenItem = index % 2 === 0 ;
console.log( "ANS: " + $item( “image1” ));
if (itemData.hide === true ) {
$w( “#image1” ).hide()
} else {$w( “#image1” ).show()}
} );
Tom