You need to sign in to do that
Don't have an account?
Som_11
I am not able to see lightining button properly in lwc
In LWC for each loop for each row I want to add button and on button click I want to call apex method passing id. Can anyone give me examples to pass if for button click with specific for each item id. And I am not able to button also properly.
My Template code
<div> <h2><b> These are the Incentives you can avail</b></h2>
<template if:true={incentives.data}>
<template for:each={incentives.data} for:item="inctv">
<div key={inctv.Id} class="slds-box">
<p key={inctv.Id}>{inctv.Name} for Target : </p> <p key={inctv.Id}>{inctv.icxdmsv1__Target__r.Name}</p>
<lightning-button key={inctv.Id}>{inctv.Name} variant="brand" label="Avail" onclick={handleGetIncentive} class="slds-button slds-button_brand slds-button_stretch"></lightning-button>
</div>
</template>
</template>
</div>
My Template code
<div> <h2><b> These are the Incentives you can avail</b></h2>
<template if:true={incentives.data}>
<template for:each={incentives.data} for:item="inctv">
<div key={inctv.Id} class="slds-box">
<p key={inctv.Id}>{inctv.Name} for Target : </p> <p key={inctv.Id}>{inctv.icxdmsv1__Target__r.Name}</p>
<lightning-button key={inctv.Id}>{inctv.Name} variant="brand" label="Avail" onclick={handleGetIncentive} class="slds-button slds-button_brand slds-button_stretch"></lightning-button>
</div>
</template>
</template>
</div>
I am posting here a sample code here for your reference where lightning button is used in iteration
testLWC.html:
testLWC.js:
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
I'Ve Made Some Changes In Your Code
Just Copy Paste This Line
Please Mark it as Best Answer If it helps
Thank you!
Try The Folloewng Code Please Mark it as Best Answer If it helps
Thank you!