Now been looking at this for hours, I don´t see it anymore, could use some help.
I register an event listener $w( ‘#btnBook’ ).onClick inside $w.onReady. It´s inside a container/repeater (on the page). The line:
console.log("btnBook data=" & JSON.stringify(data));
does not even print the text (“btnBook data”), just a 0. Same for objClickedItemData.
If I register the $w(‘#container2’).onClick((event) => {, all goes well and the data is available.
I had it working, but I screwed up somewhere. What am I doing wrong?
$w('#container2').onClick((event) => { //this one works
const data = $w('#repeater1').data;
console.log("event item id=" + event.context.itemId);
console.log("btnBook data JSON=" + JSON.stringify(data));
});
$w('#btnBook').onClick((event) => { //this one does not. data = 0
const data = $w('#repeater1').data;
console.log("btnBook data=" & JSON.stringify(data));
let objClickedItemData = data.find(item => item._id === event.context.itemId);
console.log("objClickedItemData2=" & JSON.stringify(objClickedItemData));
});