I’m trying to make a button appear or disappear on a dynamic page based on data contained in a field in my dataset. In this case I want it to show the button if “Next” is in the field or hide if it’s blank. The button IDs are named #nextleft and #nextright and their labels are hooked to fields in the database.
I feel like this should work… but it doesn’t. So apparently I’m missing something. Any help would be appreciated.
import wixData from ‘wix-data’ ;
$w.onReady( function () {
if ($w( “#nextleft” ).label === “Next” ){
$w( “#nextleft” ).show();
}
if ($w( “#nextleft” ).label === “” ){
$w( “#nextleft” ).hide();
}
if ($w( “#nextright” ).label === “Next” ){
$w( “#nextright” ).show();
}
if ($w( “#nextright” ).label === “” ){
$w( “#nextright” ).hide();
}
})
Are you calling the above code inside your dynamic dataset’s onReady() function? If not, then try it.
https://www.wix.com/velo/reference/wix-dataset/dynamicdataset/onready
Can you provide a little more information on how I would do that? I’m calling the above code on the dynamic page itself. I looked at the page you referenced but it still wasn’t clear to me what I would be doing with that.
Currently I have a Dataset called “Games”, in this dataset there’s are (text) columns named Next Button Left and Next Button Right that will either be empty or contain “Next” in them. Buttons on the dynamic page are hooked to this column and use the text within to pull the label. I want the page to hide them if that label is then blank (if there’s nothing in the column) or show them if they contain “Next”.