I have a component which will display a list of records in the table and user can edit and update each row.
Issue: Since I have static aura:id inside aura:iteration, whenever I'm trying to edit and save the second record without refreshing the page after updating the first record, it is throwing the error on component.get().
Ex Component:
<aura:iteration items="{!v.freightChargesAir}" var="fcair" indexVar="index"> <tr class="slds-hint-parent"> <td class="slds-truncate slds-size--1-of-10" data-label="Name" > <UI:inputText aura:id="frequencyEdit" value="{!fcair.Frequency__c}"></UI:inputText> </td> <td class="slds-truncate slds-size--21" data-label="dest"> <a tabindex="{!index}" onclick="{!c.saveFreightEdit}" id="{!fcair.Id}"> <lightning:icon iconName="action:record" size="x-small" alternativeText="Indicates approval"/> </a> </td> </tr> </aura:iteration>
Ex Controller:
saveFreightEdit: function(component, event, helper) { var recId = event.target.id; var frequencyfind = component.find("frequencyEdit"); var frequency = frequencyfind.get("v.value"); //Getting error here on second record save if page is not refreshed //logics goes on... } Since aura:id doesn't support dynamic Id's, I couldn't get this done as expected.
I tried replacing the UI:InputText with Lighting:input and ID attribute to get the value from DOM element but ended in no luck. Getting undefined error if I use document.getElementById.
I faced similar issue with document.getElementsByClassName as well.
Is there any way to get this working?