Hi :)
I submit to dataset2 and when I do, each item has an ID code attached.
I then submit images to dataset1. As I submit each image, they have an ID code attached (to match certain items in dataset2).
I want to filter these images to a gallery attached to my repeaters. The repeaters are populated from dataset2.
This is my code, but it's not working. When the repeaters populate from dataset2, the ID code is displayed on the repeater:
The
export function button61_click(event, $w) { // button triggers repeater to be expanded
$w("#repeater3").onItemReady( ($w, itemData, index) => {
let price = itemData.price; // to use for info on repeater
$w("#text200").text = subject + " currency name"; // info for repeater
//*the bit I can't get to work*
let refID = $w("#text208").text; // ID in repeater to match image to item
wixData.query('images') // dataset called images
.contains('title', refID) // ID to match in field 'title'
.find()
.then(res => {
{
let foundItems = res.items;
let image = foundItems.fieldName.images; //field name images
let items = $w("#gallery3").items;
items.push({
"src": image,
"description": "",
"title": ""
})
.catch( (err) => {
let errorMsg = err;
});
Anyone able to push me (no pun intended) in the right direction?
Many thanks!
Thomas
Hi Roi
Many thanks for the reply.
I've opted for a different approach in the end.
I'm using a single image on the repeater with a 'next button' on it. I'm wanting each time I click 'next' for it to show the next result from the query. I can't seem to get it working however.
My repeater is linked to a dataset called 'properties'. The image on the repeater is linked to a dataset called 'images'
let refID = $w("#text151").text; // reference number on the repeater from properties dataset (matches to the images dataset) wixData.query("images") // dataset name .eq("title", refID) //ID matched to title field .find() .then((results)=> { let item = results.items[0]; let image = item.images; $w("#image18").src = image; // shows first result $w("#button66").onClick(() => { // button on the repeater let next = results.items[+1]; let pic = next.images; $w("#image18").src = pic; // shows second image (but doesn't work for subsequent images) }) .catch( (err) => { let errorMsg = err; });
Many thanks for any help you can give!
All the best
Thomas
Hi Thomas,
Can you please share a link to your site and specify the name of the relevant page so we can inspect?
Roi.