Quick question - I know nothing about coding - I am learning along the way - so I have a member director page with a content manager and some members have pictures for their galleries and some do not. I got the gallery up and it does collapse on those pages without pictures but the problem is that it shows up when the page first loads as a black box....and only goes away after you hit the refresh.
As I mentioned I don't know code so I have watched about a million tutorials but nothing addresses this.... The code is below - any help would be greatly, and I mean GREATLY appreciated. Thank you in advance!
$w("#dynamicDataset").onReady( () => {
let item = $w("#dynamicDataset").getCurrentItem();
if (item.mediagallery) {
$w("#gallery1").show();
} else {
$w("#gallery1").collapse();
}
} );
Hello there,
First, the gallery should have the "collapsed" property "Checked" on the gallery's properties panel.
Then, you must use your dynamic dataset's onReady() event handler to check if there are any pictures being held in the database for that particular item, and expand() the gallery if and only if images were found.
$w.onReady(() => { const dataset = $w('#dynamicDataset'); dataset.onReady(() => { const item = dataset.getCurrentItem(); // Check the if there are any items if (Array.isArray(item?.mediagallery) && item.mediagallery.length > 0) { // Expand the gallery $w('#gallery1').expand(); } }) })
Hope this helps~!
Ahmad