How can i get the aura:id dynamically from event attribute, the below example i was trying to get the aura:id to get the value, else you can think as aura:id might be some field APIname so i can pass this field name and value to controller to store the value dynamically.
code
component:
<aura:component controller = "LC_AutoSave" implements="force:appHostable" >
<form>
<ui:inputtext value = "" aura:id ="testtext" blur = "{!c.autoSave}"/>
<ui:inputtext value = "" aura:id ="testtext1" blur = "{!c.autoSave}"/>
<ui:inputtext value = "" aura:id ="testtext2" blur = "{!c.autoSave}"/>
</form>
</aura:component>
Controller
({
autoSave : function(component, event, helper) {
var a = event.getSource();
console.log('Test'+a.get("v.aura:Id"));
helper.autoSavehelper(component,event);
}
})
Best Answer
I'm pretty sure you just call
component.getLocalId()
So it'd be:
Source here: