Hi,
I have an inventory page that generates dynamic item pages which have a gallery that loads images from a dataset. Each item in the dataset has exactly 20 images . These images are uploaded via a user input form.
What I’m looking for is an alternative method to load the gallery from the dataset - due to a problem I’m having only when someone does a manual page reload of a dynamic page . The code that handles this is below. The problem is the images don’t load in this specific situation. This also happens if someone copies the URL of the dynamic page and sends it to someone (email, txt, slack, …etc.), the page will open but the images will not load.
I’ve discussed the specifics of the problem with the existing code in this thread: https://www.wix.com/code/home/forum/community-discussion/dynamic-item-page-gallery-picture-load-problems
To be clear , in this thread I"m just hoping to find alternative ways to accomplish the same thing. Not necessarily trying to troubleshoot the original code (below).
import wixData from ‘wix-data’;
$w.onReady( function () {
let pic1 = $w(“#dynamicDataset”).getCurrentItem().pic1;
let pic2 = $w(“#dynamicDataset”).getCurrentItem().pic2;
let pic3 = $w(“#dynamicDataset”).getCurrentItem().pic3;
let pic4 = $w(“#dynamicDataset”).getCurrentItem().pic4;
let pic5 = $w(“#dynamicDataset”).getCurrentItem().pic5;
let pic6 = $w(“#dynamicDataset”).getCurrentItem().pic6;
let pic7 = $w(“#dynamicDataset”).getCurrentItem().pic7;
let pic8 = $w(“#dynamicDataset”).getCurrentItem().pic8;
let pic9 = $w(“#dynamicDataset”).getCurrentItem().pic9;
let pic10 = $w(“#dynamicDataset”).getCurrentItem().pic10;
let pic11 = $w(“#dynamicDataset”).getCurrentItem().pic11;
let pic12 = $w(“#dynamicDataset”).getCurrentItem().pic12;
let pic13 = $w(“#dynamicDataset”).getCurrentItem().pic13;
let pic14 = $w(“#dynamicDataset”).getCurrentItem().pic14;
let pic15 = $w(“#dynamicDataset”).getCurrentItem().pic15;
let pic16 = $w(“#dynamicDataset”).getCurrentItem().pic16;
let pic17 = $w(“#dynamicDataset”).getCurrentItem().pic17;
let pic18 = $w(“#dynamicDataset”).getCurrentItem().pic18;
let pic19 = $w(“#dynamicDataset”).getCurrentItem().pic19;
let pic20 = $w(“#dynamicDataset”).getCurrentItem().pic20;
$w(“#gallery1”).items = [ { src: pic1, }, { src: pic2, }, { src: pic3, }, { src: pic4, }, { src: pic5, }, { src: pic6, }, { src: pic7, }, { src: pic8, }, { src: pic9, }, { src: pic10, }, { src: pic11, }, { src: pic12, }, { src: pic13, }, { src: pic14, }, { src: pic15, }, { src: pic16, }, { src: pic17, }, { src: pic18, }, { src: pic19, }, { src: pic20, }];
} );