About this question
HTML:
JS:
import { LightningElement,wire,api } from 'lwc';
export default class accData extends LightningElement {
accdata;
@wire(getData, {accID: "$recordId" })
accData({ error, data }) {
if (error) {
this.error = error;
} else if (data) {
this.accdata= data.map(item => {
return{
data: item,
buttonVariant: ''
}
});
}
handleClick(event){
let dataSize = this.accdata.length;
this.clickedRec =event.target.value;
let objIndx = this.accdata.findIndex((item => item.data.Id === this.clickedRec));
this.accdata[objIndx].buttonVariant='Brand';
for (let i=0; iif(i != objIndx){
this.accdata[i].buttonVariant='neutral';
}
}
}
}
when I click the button, since it's in the loop it's changing the variant for all the buttons that are in the loop, instead how can I just change the variant of the selected button in the loop.