Hide a button if no document to download

Hello,
I am trying to get a button to hide in a repeater if there is no corresponding document to download in the dataset (impAnnouncement). The code below doesn’t report any errors but also doesn’t hide the button. Any help greatly appreciated.
Thanks,

$w.onReady(function () {
    $w("#impAnnouncement").onReady( () => {
        var hasDownload = $w("#impAnnouncement").getCurrentItem().download;
        if(hasDownload){
            $w("#btnLink").show()
        } else {
            $w("#btnLink").hide()
        }
    
    });
     
});
1 Like

Hello Michael -
your problem is you are not referencing the local scope of the repeater button ($w vs $item). See this link for a good explanation for fixing the problem - scroll down to the .at() section.

https://www.wix.com/velo/reference/$w/at

Hi Colin,

Thanks so much for your reply, however, I’m still not able to solve my issue. I might tackle this in a totally different way.

Thanks,
Michael.