All Ideas

Idea Details

Post an Idea
420  Points
Idea has been posted. Give it an upvote or downvote.

Add a custom data attribute to aura:component

Lightning Development

Sometimes, we need to attach custom metadata to a system component, like lightning:input or ui:inputSelect, in order to identify an element uniquely (e.g. because we can't dynamically assign aura:id or something else). For example, today, in Lightning, the following code can't tell us "which" item was selected:
<aura:iteration items="{!v.values}" var="item">
  <lightning:input type="text" value="{!item}" onchange="{!c.update}" />
It would be convenient if we could attach some custom data to the element:
<aura:iteration items="{!v.values}" var="item" indexVar="index">
  <lightning:input data="{!index}" type="text" value="{!item}" onchange="{!c.update}" />
Ideally, the only change that needs to be made is adding a single line of code to aura:component;
<aura:attribute name="data" type="Object" access="GLOBAL" />
Since all components inherit from aura:component, this would immediately give us the ability to attach custom data to system components, in the same way that we could attach data to Visualforce components with HTML passthrough attributes.

Merge Idea · Flag

  • Upvotes
  • Downvotes



from AppExchange


Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.