Contents
The following example component creates two buttons to contrast an HTML button with , which is a standard Lightning component. Clicking on these buttons updates the text component attribute with the specified values. target.get (“v.label”) refers to the label attribute value on the button.
What do you need to know about lightning component framework?
The Lightning Component framework allows developers to define client-side controllers with methods that respond to client and server-side events. Learn how different controller types works together in a component.
How are Lightning components written in JavaScript?
Client-side (JavaScript) Controllers for Lightning Components. The client-side controllers are written in JavaScript and are automatically placed in a file in the component bundle named Controller.js. Let’s look at a component and its controller that allows a user to update a Contact.
How are lightning controllers similar to Visualforce controllers?
The Lightning Apex controllers are similar to Visualforce controllers that only contain @RemoteAction methods. The Apex controller for the contact component has two methods defined that can be invoked from the component’s JavaScript. ? Methods in the Apex controller that can be called must be static and annotated with @AuraEnabled.
The way to go is to use event.getSource (): The solution is to build your own button component, using an Aura.action attribute (no need to create a new event) 🙂 Thanks for contributing an answer to Salesforce Stack Exchange!
What is a client side controller in JavaScript?
A client-side controller handles events within a component. It’s a JavaScript resource that defines the functions for all of the component’s actions. A client-side controller is a JavaScript object in object-literal notation containing a map of name-value pairs. Each name corresponds to a client-side action.
Where is the text component attribute in JavaScript?
The text component attribute is defined in the tag in the markup. Use unique names for client-side and server-side actions in a component. A JavaScript function (client-side action) with the same name as an Apex method (server-side action ) can lead to hard-to-debug issues.
How to create a client side controller in Salesforce?
A client-side controller is part of the component bundle. It is auto-wired via the naming convention, componentNameController.js. To create a client-side controller using the Developer Console, click CONTROLLER in the sidebar of the component.