I have a repeater on my page that has a repeating button. Each button has a different label (manually edited) . I want each button to have an onClick event that changes the text of some text on the page to be equal to the label of the clicked button. I tried this code but the event does nothing.
$w.onReady(function () { $w("#rptStageSelect").onItemReady( ($item, itemData, index) => { $item('#rptStageSelectButton').onClick( () => { $w('#text4').text = $item('#rptStageSelectButton').label; }); }) });
In the above code rptStageSelect is the repeater, rptStageSelectButton is the button in the repeater, text4 is a text box on the page. Clicking on the button shoud change the text of text4, but it does not.
I tried the next code as a walk-around:
export function rptStageSelectButton_click(event) { $w('#text4').text = $w('#rptStageSelectButton').label; }
But this gives me bad results - the text in text4 always becomes the text of the label of the first button, to matter which button I click in the repeater.
I am new to Velo and would appreciate some advice.
Hi, you can try something like this:
$w.onReady(function () { $w('#rptStageSelect').onClick((event)=>{ let $item = $w.at(event.context); $w('#text4').text = $item('#rptStageSelect').label }) })