Hi there. I have a repeater with an image and some text fields. If the image field is empty, I don’t want to have the placeholder spacing, so that there is no empty field, but the elements line up without spacing.
How can I code this?
That’s the URL: https://www.franziskaroth.ch/komitee
Until now I worked with placeholders, but it looks unattractive.
THANKS.
Hi,
To accomplish this you can use the repeater element’s onItemReady() function to collapse() the image element when it finds a empty image field in a particular item.
Initially, I setup a repeater with a dataset that connects the text and image field from a collection.
Next, I used the following code to collapse a image when the field is empty:
$w.onReady(function () {
$w('#repeater').onItemReady(($item, itemData, index) => {
if (!itemData.image) { //Checks if Image field is Empty
$item("#repeatedImage").collapse();
}
});
});
As this is an example, you’ll need to make sure the element and field ids are correct according to your page if you use this code.
1 Like