You need to sign in to do that
Don't have an account?

I want to get the Id from lightning component
<button class="slds-button slds-button--icon-border slds-float--left" aria-live="assertive" type="button" onclick="{!c.test}" value="{!ideas.Id}">
<c:svgIcon svgPath="/resource/slds221/assets/icons/utility-sprite/svg/symbols.svg#like" category="utility" size="small" name="down" class="slds-button__icon slds-button__icon--large" />
<span class="slds-assistive-text" id="like" title="like">Like</span>
</button>
javascript code
test:function(cmp,event){
var ideaID = event.currentTarget.dataset.ideasID;
alert(ideaID);
}
<c:svgIcon svgPath="/resource/slds221/assets/icons/utility-sprite/svg/symbols.svg#like" category="utility" size="small" name="down" class="slds-button__icon slds-button__icon--large" />
<span class="slds-assistive-text" id="like" title="like">Like</span>
</button>
javascript code
test:function(cmp,event){
var ideaID = event.currentTarget.dataset.ideasID;
alert(ideaID);
}
A component has two types of IDs: a local ID and a global ID. You can retrieve a component using its local ID in your JavaScript code. A global ID can be useful to differentiate between multiple instances of a component or for debugging purposes.
To find the local ID for a component in JavaScript, use cmp.getLocalId().
To retrieve a component’s global ID in JavaScript, use the getGlobalId() function.
For detailed information please check with below link:
- https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_ids.htm
Hope this helps.Please mark this as solved if it's resolved.
Thanks,
Nagendra.