I’m having trouble with
I’m writing Velo/Javascript code in the $w.onReady() handler to hide/show an element on a dynamic page that shows a scheduled event. I would like to hide/show the element based on whether or not the event has a certain category assigned to it. (For example, show “Event ending soon!” if the “EndingSoon” category is set for that event.) Using code like:
$w("#dynamicDataset").onReady(() => {
// Get the current item from the dataset
let currentItem = $w("#dynamicDataset").getCurrentItem();
console.log( "The categories are " + JSON.stringify(currentItem.categories));
});
I can retrieve the event, but the categories field shows as an empty array, even though the event itself has multiple categories set. (If I display the currentItem contents, it shows proper values for the other fields.) Any ideas on how I can retrieve the categories for the event? Once I had the categories for the event, I could test to see if the one that I need is present and call show() or hide() on my element, but at the moment I am stuck on how to get the list.
Working in
Dev Mode