Event handling in Lightning base components

Base components are components with the namespace as Lightning. Some base components are Lightning:button, Lightning:buttonGroup, Lightning:input.

Such components do not expose you to the DOM; hence, using event.target or event.currentTarget will not work, due to Locker Services (note that the Locker Service prevents accessing the DOM of other components if they are from different namespaces). For such components, you can use the following syntax to get the value of the attribute:

event.getSource().get("v.attributename") 

To set the attributes of the component element, use the following code:

event.getSource().set("v.attributename","value") 

In order to understand how to work with event handling ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.