Dynamic Lightbox From Repeater

Thank for reply
Here is a sample of code that doesn’t work
The target is to open different Lightboxes (with data passing) for any related item in repeater on dynamic page.


import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

let iQuery = wixData.query('Items');
let pQuery = wixData.query('Persons');
let lightboxName;
let dataObj;

$w.onReady(function  ()  {    
    $w("#aDataset").onReady(()  =>  {         populateCalculatedFields();     });     
    $w("#aDataset").onCurrentIndexChanged((index)  =>  {         populateCalculatedFields();     });
}); 

function  populateCalculatedFields()  {    
 const  currentItem  =  $w("#aDataset").getCurrentItem();    
 
    $w("#aTitleText").text  =  currentItem.pFullName;
    setAuthorItemsRepeater();
} 

function setAuthorItemsRepeater() {
const  currentItem  =  $w("#aDataset").getCurrentItem();    
 let asObject = currentItem._id
    iQuery
        .eq('iAuthor', asObject)
        .include('iKeeper')
        .find()
        .then((results) => {
            console.log(results.items);
            $w(`#aiRepeater`).data = results.items;
        }) //console.log(results);
        .catch((error) => {
 let errorMsg = error.message;
 let code = error.code;
        });
    $w('#aiRepeater').onItemReady(($w, iData, index) => {
 
        $w("#aiNameText").text = iData.iName;
 
 if (iData.iKeeper !== null && iData.iKeeper !== undefined) {   
   $w('#adoptButton').label = 'Look';
   lightboxName='Hall';
   dataObj=iData.iKeeper; //include                      } else {
   $w('#adoptButton').label = 'Take';
   lightboxName='Artwork';
   dataObj=iData.iKeeper;}
        $w(`#adoptButton`).onClick((event)=>{ wixWindow.openLightbox(lightboxName, dataObj)   });
    });
}

import wixWindow from 'wix-window';

$w.onReady(function () {
let receivedData = wixWindow.lightbox.getContext();
$w('#kImage').src = receivedData.pImage;
$w('#kTitleText').text=receivedData.pFullName;  .
});

Currently even open Lightbox with lightboxName as parameter doesn’t work

May be it is scope/context issue?

!!!https://www.wix.com/code/home/forum/wix-tips-and-updates/removal-of-the-w-parameter-from-event-handlers
https://www.wix.com/code/home/forum/wix-tips-and-updates/removal-of-the-w-parameter-from-event-handlers
https://www.wix.com/code/home/forum/wix-tips-and-updates/connecting-your-database-to-lightboxes
Please urgent help