custom event page

Hi, I’m trying to generate code for a custom event page.
The code should hide the button “button17” when the value of type is equal to “View only”.
I wrote the attached code and it doesn’t work for me.
I would appreciate your help.

import wixLocation from ‘wix-location’ ;
import wixData from ‘wix-data’ ;
import events from ‘wix-storage’ ;
import wixEvents from ‘wix-events’ ;

export function dynamicDataset_ready ( ) {
let typeElement = $w ( “#dynamicDataset” ). getCurrentItem (). type ;

if ( typeElement . value === “View Only” ) {
$w ( “#button17” ). hide ();
$w ( “#button18” ). show ();
}

}

A few things are looking off here to me…

  1. where is your page onReady and datasetOnReady code?

  2. what is returning for typeElement? (you can use a console.log() to check this)

References that may help you with your code:
https://www.wix.com/velo/reference/wix-dataset/dynamicdataset/getcurrentitem

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