I got a table with an account list, as such:
<table>
<aura:iteration items="{!v.accounts}" var="acc">
<tr>
<td>
<a onclick="{!c.deleteAccount}" id="{!acc.Id}">
<lightning:icon iconName="utility:delete" size="small" alternativeText="Delete"/>
<span class="slds-assistive-text">Delete</span>
</a>
</td>
<td>{!acc.Name}</td>
</tr>
</aura:iteration>
</table>
How can I dynamically replace the <lightning:icon iconName="utility:delete />
part with a spinner only for the table row that was clicked?
If I do something like
<table>
<aura:iteration items="{!v.accounts}" var="acc">
<tr>
<td>
<aura:if isTrue="{!v.accountIsBeingDeleted}">
<div style="height:1rem; position:relative; margin-right:1rem">
<div class="slds-spinner_container">
<div role="status" class="slds-spinner slds-spinner_x-small slds-spinner_brand">
<span class="slds-assistive-text">Loading</span>
<div class="slds-spinner__dot-a"></div>
<div class="slds-spinner__dot-b"></div>
</div>
</div>
</div>
<aura:set attribute="else">
<a onclick="{!c.deleteAccount}" id="{!acc.Id}">
<lightning:icon iconName="utility:delete" size="small" alternativeText="Delete"/>
<span class="slds-assistive-text">Delete</span>
</a>
</aura:set>
</aura:if>
</td>
<td>{!acc.Name}</td>
</tr>
</aura:iteration>
</table>
it will (obviously) show a spinner for all rows in the list, rather than the specific row clicked.
The function for deleting is quite straightforward:
deleteAccount: function (component, event, helper) {
component.set("v.accountIsBeingDeleted", true) // this part
// call helper function to delete account
},
Any pointers?