I have a list of records and an accordion style form for each record:
this is achieved with aura:iteration and few <tr>
tags.
I've used the indexVar on aura:iteration to uniquely identify records, i.e.
<div id={!'myDiv'+i}>
. This has worked well, except now I am trying to actually get fields form the forms.
Let us say we have three text input fields:
input1 [ ]
input2 [ ]
input3 [ ]
I want to automatically save the values in the form onChange. Ideally, we would simply pass the value to a JS controller which would handle the save.
Using default markup attributes do not work:
onclick
gets stripped (struck?) away by lightning. They prefer you use <ui:inputText>
. This is fine since it has the change attribute, but you can't set ID's dynamically on them. You cannot define the id attribute on a ui-element (<ui:inputText id='..'
throws an error). You also cannot dynamically set aura:id (aura:id={!'myDiv'+i}
does not work).
So back to our three input fields example, how can you find the correct inputText field? There may be hundreds of inputText fields, and we need to know which input field has changed and which value it has changed to.