I'm one of the many trying to conditionally collapse elements in a repeater on a dynamic page. For some unknown reason, I can't get my function to trigger on the empty text field.
My text field is within a container box and if the text element is empty, I would like to collapse both the text and the container box. Note that the code does seems to execute if I try to compare non-blank values to something loaded in the database field (such as comparing "dog" to the same loaded in the database, but I don't seem to have success detecting an empty field????
Have read the various attempts on this subject and have lifted and tried many variations - here is what I have tried in terms of the comparison
=== undefined
=== ""
=== ''
Also tried the if (!itemData.description)
Here's my code with just one of the variations I've tried:
export function repeater1_itemReady($w, itemData, index) { $w("#repeater1").onItemReady(() =>{ if (itemData.description === undefined) { $w("#text85").collapse(); $w("#box5").collapse(); } }); //Add your code for this event here: }
Would greatly appreciate it if someone could take a look and explain what I must be missing or why I would see different behavior when I define a string as a non-blank.
Deborah
Yes, I had more standard code before but have had no luck for quite a while and couldn't get it to work.
For now I'm going to let that sleeping dog lie.
One more question if you please, I need to do the same sort comparison on another field, but this one through a reference database accessed through the same repeater. What would be the proper syntax? My reference db field is newTitle1 and I am trying to assess whether a field in that database is blank as well.
This clearly doesn't work ...
if (!itemData.newTitle1.videoLabel) { $w("#button6").collapse();
Great, but looking at it again, I do not see how: you magically mixed up the stub function from the property panel
exportfunction repeater1_itemReady($w, itemData, index) {
with the event itself
$w("#repeater1").onItemReady(() =>{
Looks like you have tried many things. Can´t even explain why it works, but if it does, good on you.
This time it worked! Unbelievable - guess I just needed to post here. Thank you!
I have tried that (see above) but I'll give it another try ...
Try this:
if (!itemData.description) {