Hello! I am currently creating a repeater containing member bios. Some members have roles assigned to them, which is populated in my database as a text field. However some members do not have a role, and I am looking for a way to collapse the empty text field that would display their role.
I have found a way to collapse all the role text fields for all repeater items, but I want a way where only empty text fields are collapsed for some repeater items.
Here is what I have so far:
$w("#repeater1").onItemReady(($item, itemData, index) => {
if (itemData.role === undefined) {
}
});
As you can see, I'm not 100% sure of a way to collapse the specific empty text fields. Thank you for reading and I appreciate any help!
Hi Joanneh!
Inside your if statement simply add the name of the element and use the collapse( ) function that exists for the element.
It should look something like this:
$w("#repeater1").onItemReady(($item, itemData, index) => { if (itemData.role === undefined) { $item("#yourTextElement").collapse() } });
I'm not sure as if the itemData.role should be compared to `undefined` or to " " (as in empty string).
If one doesn't work just try the other. It depends on the type of your field.
Let me know if it works for you.
Doron.