Hiding elements on page using Dataset connection

I have a page where I am not using a dynamic page, but I do have a Dataset connection on the page. I use a Velo to hide elements on dynamic (Title) pages. However, this code doesn’t seem to work in this case because I suspect the tag for ".getCurrentItem(); does not apply here.

$w . onReady (() => {
$w ( “#datasetAward” ). onReady (() => {
// Gets the current item properties and stores them in a variable called item
const item = $w ( “#datasetAward” ). getCurrentItem ();
// Checks if the current item has a value in the “video” field
if (! item . awardUrl ) {
// Collapses the video player if there is no value for “video”
$w ( “#button1” ). collapse ();
}

});
});

What should I do on this page
https://iamteejay.editorx.io/lgla2021/awards

To hide the VIEW AWARDS button from a list on a standard page using a dataset connection? Is there something I can replace

const item = $w ( " #datasetAward " ). getCurrentItem ();

with?

My IDs are

Dataset: #datasetAward
Button: #button1

Thanks in advance.

I’ll ask the guys from the Velo team to see if they shed some light @teejay !

Hi @teejay ,

You are correct that getCurrentItem does not apply here. When working with datasets in repeaters, you actually need to iterate through the repeater UI element using the onItemReady() function for repeaters . So the code is going to look more like this:

$w('#repeater').onItemReady( ($item, itemData) => {
    if(!itemData.awardUrl) {
        $item("#button1").collapse();
    }
});

This will iterate through every rendered “row” in your repeater to relates to a row in the dataset and look at the repeater UI elements in the context of the current Item (similarly to how getCurrentItem does it on dynamic pages). This lets you look at the data for a row, itemData, and make decisions for the UI elements related to that data, where $item is your new $w when iterating through the repeater.

Hope this helps!

Meredith

Applied the code, but sadly with no effect to the button hiding if not data is present. Checked all my IDs.

Might there be some additional code the wraps around it which would ID the the dataset?

@teejay make sure the repeater onItemReady is inside your $w.onReady(). I don’t see the page onReady code anymore.

Yep, forgot to wrap it. Thanks Meredith!

Hi everyone!

I’m still very new to the editorx website creation platform although with the help of resources online I am finally getting an edge of it. However, I am currently facing an issue (one of a few)

I am designing a repeater for a real estate website (you know how items in a repeater is seamless across all containers in a repeater, right) and I discover that I don’t need certain items to show in a container inside the repeater ( one is a button, the other is a text, and then another is an image)

So here’s my question;

How do I remove/hide certain items in a container inside a repeater without affecting the display across other repeater boxes?

I’ll appreciate your feedback.

Thanks.

@meredithh

If you have some familiarity with coding, you can try modifying this example to your liking:
https://support.wix.com/en/article/velo-tutorial-hiding-a-video-player-when-there-is-no-video-to-play