Open a lightbox

Hi
So, I have a table from which I want to open a lightbox with a click but the light box opens only by clicking on the second line that is clicked. This is the code, ideas?

// this is the code -
let items;
$w.onReady(function () {
// here so that the lightbox opening would be faster
items = $w(“#dataset1”).getItems();
});

let didUserSelect = 0
export function table1_rowSelect(event) {
if (didUserSelect === 0) {
didUserSelect = 1
return
}
items.then(result => {
wixWindow.openLightbox(“View”, {
currentIndex: event.rowIndex,
items: $w(‘#table2’).rows
});
});
}
// end of the code

Hey Hadar,

Can you please send us your site URL? Moreover, can you please clarify why did you defined the " didUserSelect " variable? Note that the " table1_rowSelect " function will be execute only when a row is selected. You can read more about it here .

Awaiting your reply,
Tal.

Hey Hadar,

As mentioned above, there’s no need to use a promise in order to open a lightbox and sending the relevant row data. Note that the first index ( zero ) is referring to the first data row and not the headline of the table (meaning in your case, the first index of the table is referring to the " מהנדס מים לעיריית תל אביב " row ).
Therefore, the code should be much simpler:

export function table1_rowSelect(event) {	
	wixWindow.openLightbox("View", {
			currentIndex: event.rowIndex,
			items: $w('#table2').rows
		});
}

I hope it’s clearer now.

Best,
Tal.

Hi Tal
It’s working now
(:
thanks!