I need a way to keep track of each iterated lightning:inputField so that any changes made to that specific field is reflected by a CSS style change.
Markup
<aura:iteration items="{!v.layoutAPIFieldsList}" var="e" indexVar="i">
<aura:if isTrue="{!e.APIName != 'requestDocType__c'}">
<lightning:layoutItem padding="around-small" size="6">
<lightning:inputField aura:id="{!e.APIName}"
fieldName="{!e.APIName}"
onchange="{!c.changeInputField}" />
</lightning:layoutItem>
</aura:if>
</aura:iteration>
JS Controller
changeInputField : function(component, event, helper){
var cmpTarget = component.find(/* Iterated Variable */);
$A.util.addClass(cmpTarget, 'unsavedChanges');
},
Here in the JS is where I want to pass the iterated variable and apply the CSS. Maybe I should locate it by index or aura:id?
event.getSource()
will give you a reference to the component. So you should be able to pass it in to theaddClass()
function?