I have a repeater that is bound to a dataset. The dataset is read / write. I have a button that is displayed on each item in the repeater. I have added a click handler to the button in the repeater. In the handler, I am calling getCurrentItem() of the dataset, but no matter which item I click on, getCurrentItem() returns the first item in the dataset. How do I get the actual current item?
export async function pickupButton_click(event) {
console.log($w("#dataset1").getCurrentItem()); // Always returns the first element in the dataset, no matter which element is clicked on
}
@zackgreenberg To have getCurrentItem return the data of the row which you clicked, you need to use the at() function . You would then use $item instead of the typical $w when you reference a repeater item.
export async function pickupButton_click(event) { let $item = $w.at(event.context); console.log($item("#dataset1").getCurrentItem()); }