Get and use data from repeater

I have a repeater connected to a dataset. The repeater has a container. The container has 4 items. Image, text1, text2, button. In the page I have another text box - text3. I want to click the button on the container and when doing that pass the text of either text1 or text2 to text3.
Tried everything around this but no success.

//$w.onReady( function () {
//$w(“#container1”).onClick( () => {
//let clickedItemData;
//clickedItemData = $w(“#dataset1”).getCurrentItem();
//$w(“#text20”).text = clickedItemData[1];
//} );
//} );

$w.onReady( () => {
$w(“#dataset1”).onReady( () => {
$w(“#container1”).onClick( () => {
let clickedItemData;
clickedItemData = $w(“#dataset1”).getCurrentItem();
$w(“#text20”).text = clickedItemData[0,0];
} );

} );

} );

//export function button1_click() {
// clickedItemData = $w(“#dataset1”).getCurrentItem();
// $w(“#text20”).text = clickedItemData;

//}
PLEASE HELP !!!

Hay Arthur,

the onClick event gets two parameters - the event itself and a scoped $w. If you use the scoped $w, you will get the values of the specific item in the repeater.

e.g.

export function button1_click(event, $w) {
	clickedItemData = $w("#dataset1").getCurrentItem();
	$w("#text20").text = clickedItemData;
}

Doesn’t work


Parameter ‘event’ is never used

when i click the button in preview mod:
Wix code SDK error: The text parameter that is passed to the text method cannot be set to the value [object Object]. It must be of type string.

Do I need the rest of the code or just the lines you put in your post ?
changing the code like this:
export function button1_click(event,$w) {
clickedItemData = $w(“#dataset1”).getCurrentItem();
$w(“#text20”).text = clickedItemData[1];

returns:
Wix code SDK Warning: The text parameter that is passed to the text method cannot be set to null or undefined.
when clicking the button

Hi,
getCurrentItem method return an object. I guess you want to display one of the values inside the object.
So, $w(" #text20 ").text should be equal to clickedItemData.someFieldKey.
Please update your progress.
Roi

But this returns the text from the object and not from the dataset connected to it. I want to get the particular instance of the data where I clicked.

did you find a solution? I want to create a button that copies all the reapetar data into a single string concatenating the contents of its text box…

Exact same issue, sadly no resolution. I too am getting Wix code SDK Warning: The text parameter that is passed to the text method cannot be set to null or undefined

export function text36_click(event, $w) {
const data = $w(“#dataset1”).getCurrentItem();
namevalue = data.StockingName;
$w(“#clickedstocking”).text = namevalue;

}

It is always said that to create a new post, because this is an old one…

#repeater1 - repeater

$w('#repeater1').onItemReady($item, itemData, index) => {
 $item('#text16').onClick((event) => {
  let value = itemData.StockingName;
  $w('#clickedstocking').text = JSON.stringify(value);
 });
});

hi, i have done this before through getcurrentitem. but now it is not working. did wix change some rules in coding? any feedback on this?

Hey, guys! I did it. Try code below

export function button4_click(event, $w) {
console.log($w( '# dataset id ’ ).getCurrentItem());
$w( '# textinput ’ ).value=$w( '# text2 ’ ).text;
}