Button on repeater that sends an email to an address from the item in the dataset, with a subject from the dataset.

I have a repeater set up that pulls information from a dataset. I have added a button to the dataset to email the contact email address in the dataset, with a specific field as the subject.

It works, but no matter which item in the repeater you click the button on, it always takes the details from the first item. I’m new to this, had a good search on here and couldn’t find an answer.

If anyone could help it would be greatly appreciated - even pointing me to another post.

Code:

import wixLocation from ‘wix-location’ ;

export function button3_click(event) {
let emailaddy= $w( “#dataset5” ).getCurrentItem().contactEmail
let opportunity = $w( “#dataset5” ).getCurrentItem().roleTitle

wixLocation.to( "mailto:" +emailaddy+ "?subject=Talent%20Opportunity%20-%20" +opportunity); 

}

See here:
https://www.wix.com/corvid/reference/$w.Repeater.html#onItemReady

Hi Stacey this is the valid code for what you need ive found on here elsewhere which is what i was looking for too

export function repeater1_itemReady($item, MyDataBase, index) {

 // Set the contact button to create an email to the user whose request was dismissed.
    $item('#button3').onClick(() => {
 const subject = "Talent Opportunity -";
        wixLocation.to(`mailto:${MyDataBase.contactEmail}?subject=${subject}${MyDataBase.session}`);
    });

}

you just need to change where it says “MyDataBase” for yours also the “repeater1” name