JS debugger - getCurrentItem() value unknown

Hi,
I’m trying to debug a page code where getCurrentItem() of dataset is invoked after repeater item is clicked.
I’m using the Chrome JS debugger but I’m not able to view the result value of getCurrentItem() although it does get logged using console.log().
I’m trying to understand why does it behaves like this, I set the result of the getCurrentItem() into a JavaScript regular variable so why is it not showing any value?

BTW - I’m able to set a breakpoint to the clickedItemData line as well.

The code is:

// API Reference: https://www.wix.com/corvid/reference
// “Hello, World!” Example: https://www.wix.com/corvid/hello-world

$w.onReady( function () {
// Write your JavaScript here

// To select an element by ID use: $w(“#elementID”)

// Click “Preview” to run your code
console.log( “on ready” );
});

export function container3_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
debugger ;
let $item = $w.at(event.context);
let clickedItemData = $item( “#dataset1” ).getCurrentItem();
console.log( "clicked " + JSON.stringify(clickedItemData));
}

Attached the screenshot of the Chrome debugger.

I’d try:

$w.onReady(() => {
    $w("#dataset1").onReady(() => {
        $w("#container3").onClick(event => {
            //code here.
        })
    })
})

P.S. It probably won’t solve the problem, but try it anyway.

  • Maybe I’m wrong but I don’t think $item(“#dataset1”) can work as the dataset is not a a scoped selector.

If it’s a repeater, you can try:

export function container3_click(event) {
const clickedItemData = $w("#repeater1").data.find(e => e._id === event.context.itemId);
}

@jonatandor35 This is taken from Corvid API spec and it works ok. When the repeater is blinded to a dataset then the second method should be used.

My question is about the javascript debugger and not exactly about the code. Seems to me that it does not behaves correctly or wix javascript line of code is not native ( let clickedItemData = $item( " #dataset1 " ).getCurrentItem():wink: so the debugger cannot debug it.