I have a table connected to Dataset on a dynamic page. The table contains a column of images.
I’m trying: when an image is clicked show a popup of the image.
I did the following steps:
Get the image data by creating an onCellSelect event, open a lightbox and send the image source to the lightbox. This code should be added to the page section where the table is added:
import wixWindow from 'wix-window';
export function table1_cellSelect(event, $w) {
let cellData = event.cellData;
//the cell containes an image
if (cellData.indexOf("image://") !== -1){
wixWindow.openLightbox("lightbox", cellData);
}
}
Create a lightbox and add an image as a placeholder.
Get the image source using the getContext function and change the image source to the received image data. This code should be added to the page section of the lightbox:
As usual, the images is uploaded to Image column in Products Database from Media (site files). table1 is located in a dynamic page and connected to Products Database . The first column in table1 retrieves images from the Products Database.
(note i have empty cells in the Image column of Products Database since the site content is not fully prepared - but the error appears when i click on images and not empty cells).
Do you need some more info to help me understand how i’m solving this?
I still have trouble with the above.
Getting now this Error:
TypeError: cellData.indexOf is not a function
Refresh =>
I have a table in a dynamic page connected to a dataset, the first column of the table retrieves images (uploaded to database from media > site files, yes the type of column in the database is correct).
I’m trying to link the images that in the table to a Lightbox, i.e. when a cell populated with an image is clicked the image will popup.
Using the following Code:
code inserted in Lightbox: