event in lightning component -- w3web.net

A Simple Example of Application Event Handling Between two Custom Lightning Components in Salesforce

Hey guys, today in this post we are going to learn about how to communicate between two custom component using application event.

Real time scenarios:- Create an event in Salesforce lightning, and Checked the Value of Checkbox from parent component to child component on click button in Lightning Component using Application event.

Files we used in this post example:-

eventApp1.app Lightning Application It is used for call the component to preview on browser.

eventRegisterCmp1.cmp

Lightning Component It is a parent component and hold a click button.

eventRegisterCmp1Controller.js

JavaScript Controller File It is used for click function for Checkbox Checked the Value.
eventHandlerCmp1.cmp Lightning Component It is a child component of eventRegisterCmp1.cmp, It is hold checkbox input.
eventHandlerCmp1Controller.js JavaScript Controller File It is fire automatically and get the value of event from parent component and set value of attribute.
repCheckboxEvent.evt Lightning Event Creat a application event, hold a boolean type attribute that default value is false.

Live Demo

event in lightning component -- w3web.net

Other post that would you like to learn

Step 1:- Create Lightning Application : eventApp1.app

From Developer Console >> File >> New >> Lightning Application

eventApp1.app [Component Application File]

Step 2:- Create Lightning Component : eventRegisterCmp1.cmp

From Developer Console >> File >> New >> Lightning Component

eventRegisterCmp1.cmp [Lightning Component File]

Step 3:- Create Lightning Component : eventRegisterCmp1Controller.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

eventRegisterCmp1Controller.js [JavaScript Controller]

Step 4:- Create Lightning Component : eventHandlerCmp1.cmp

From Developer Console >> File >> New >> Lightning Component

eventHandlerCmp1.cmp [Lightning Component File]

Step 5:- Create Lightning Component : eventHandlerCmp1Controller.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

eventHandlerCmp1Controller.js [JavaScript Controller]

Step 6:- Lightning Event : repCheckboxEvent.evt

From Developer Console >> File >> New >> Lightning Event

repCheckboxEvent.evt [Lightning Component File]

Further post that would you like to learn

Leave a Comment

Contribute to Support If Some Value Added in Your Project or Website