I have a database that contains a few image urls to an external site along with some other data. I’m trying reset a gallery images with the images in the url, and its not resetting.
Does anybody know how I might accomplish this?
Below is my code snippet, where currentItem is a record in the database. modelYear, modelExact, and images’ + i + ‘Uri’ (images0Uri, images1Uri, images2Uri…) are fields in the database.
$w.onReady(function () {
function createImageItem(itemNum, dataItem){
var item = {"type":"image",
"alt": dataItem.modelYear + " " + dataItem.modelExact + " - Image " + itemNum,
"title": dataItem.modelYear + " " + dataItem.modelExact,
"src": dataItem['images' + i + 'Uri'] };
return item;
}
let currentItem = $w('#dynamicDataset').getCurrentItem();
$w('#gallery').items = [];
let photoItems = [];
for(var i = 0; i < 14; i++){
if(currentItem['images' + i + 'Uri']){
var photoItem = createImageItem(i, currentItem);
photoItems.push(photoItem);
}
}
$w('#gallery').items = photoItems;
});