Hi, My final goad is to collapse the gallery if there is no connected pictures in the collection in database. I use the code as shown in the manual , but I keep getting empty object. Please help. My code:
$w.onReady(function () {
let myitems = $w("#gallery1").items;
console.log(myitems);
});
I keep getting empty object, but there are pictures in the collection and the connection of the gallery to the collection is working. That is WIX Pro Gallery. Please help!
May be that’s because the code is loaded earlier than the gallery?
Here is the solution:
let myitems = $w('#dynamicDataset').getCurrentItem().gallery;
Hi 
You cannot set or get the Pro Gallery items if you set their items through the editor, you can only set or get its items if it was populated by a dataset or by a code.
If you’re populating the gallery by a dataset, you need to make sure that the dataset is ready before you can retrieve the gallery’s data, to do so, you need to use the dataset’s onReady() function.
$w('#dataset').onReady(() => {
let myitems = $w("#gallery1").items;
})
Hope this helps~!
Ahmad