Hi. I created a publication page using a repeater and would like to hide or grey out the button link for entries that are not officially published.
What’s the best way to do that? Thank you!
Hi. I created a publication page using a repeater and would like to hide or grey out the button link for entries that are not officially published.
What’s the best way to do that? Thank you!
There might be alternative ways to approach it, but here’s how I would approach it:
Add a boolean field in the collection. Let’s call it “Published”
Then you’ll need a little code (I imagine you’re using a dataset to connect to the repeater). Something like:
$w.onReady(function () {
$w("#dataset").onReady(() => {
$w("#repeater").onItemReady(($item, itemData, index) => {
if (itemData.published) {
$w("#button").disable()
} else {
$w("#button").enable()
}
})
})
});
You’ll need to update the IDs to be relevant to your project/site elements
Putting Repeater.onItemReady within Dataset.onReady would cause the trigger to be replicated every time the dataset reloads (filtration, pagination)
So, say the user goes to the next item page, now the onItemReady function will fire twice for every item that loads, and thrice when they load the next one
Putting it within $w.onReady may not be necessary either, but it poses no problem
Good catch! I generally load data without datasets, so forgot about this one ![]()