function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jkcjkc 

Dynamic aura:id

Hi,

Is it possible to make aura:id dynamic? because when I try to get the aura:id in the controller using getLocalID I'm getting 
{!'index' + index}.

<aura:iteration indexVar="index" items="{!v.actions}" var="obj">
     <tr aura:id="{!'index' + index}">                                    
          <td>
              <ui:inputCheckbox aura:id="{!'index' + index}" change="{!c.changeCheckbox}" >
                   {!'index' + index}
               </ui:inputCheckbox>
         </td>
         <td>
              {!obj.Summary__c}
         </td>
         <td>
              {!obj.Due_Date__c}
         </td>
         <td>
              {!obj.User__c}
          </td>
     </tr>                                    
</aura:iteration>
Best Answer chosen by jkc
bdvorachekbdvorachek
aura:id doesn't support expressions. You can only assign literal string values to aura:id.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_ids.htm

All Answers

James LoghryJames Loghry
For the line 2, you are using a simple tr element, so you can get away with id instead of aura:id.  If you're concerned with line 4, it looks like your syntax is a bit off.  Try aura:id="{!index}index" instead.
bdvorachekbdvorachek
aura:id doesn't support expressions. You can only assign literal string values to aura:id.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_ids.htm
This was selected as the best answer
Prasenjit Barua 4Prasenjit Barua 4
Hi All,
I am facing one isue to dynamically accessing the index of map 

 <aura:iteration items="{!v.NumberOfItr}" indexVar="outindex" var="outItem">
    <aura:iteration items="{!v.SobjectObjmap[outindex][0]}" var="mapItem">

This is giving Failed to save undefined: expecting a positive integer, found 'outindex' at column 17 of expression: v.SobjectObjmap[outindex][0]: Source error

Would appreciate any help.
Thanks


 
Dharanee KDharanee K
Hello Prasenjit
you able to acheive this?