[Solved] Image icon/tag showing although dataset field is empty

Hi Helena:

OK This is the error being reported by the browser:


What this is saying is that it doesn’t know what to do with this code on line 1.

$w("#repeater1").onItemReady( ($w, itemData, index) => {

There is also another problem and that is that you only need one of these blocks not two. So you need to consolidate the two onItemReady functions into one.

The way to make sure that the selector is usable is to use it either in a function or, in this case, the page onReady function like so.

$w.onReady(() => {
    $w("#repeater1").onItemReady( ($w, itemData, index) => {
        console.log(itemData.image2);
        if(itemData.image2 && itemData.image2.length > 0) {
           $w("#image25").show();
        } else { 
           $w("#image25").hide();
        }
        console.log(itemData.image3);
        if(itemData.image3 && itemData.image3.length > 0) {
            $w("#image24").show();
        } else { 
            $w("#image24").hide();
        }
    });

    $w("#dynamicDataset").onReady( ($w, itemData, index) => {
        console.log(itemData.document);
        if(itemData.document.length > 0) {
            $w("#button4").show();
        } else { 
            $w("#button4").hide();
        }
    });
});

Try this and see if it works.

Cheers
Steve