Topics for this chapter:
- Handling Browser Events
The lightning framework uses event-driven programming model. We need to write handlers which respond to the event as they occur.
Events can be triggered by the user or can automatically be fired by the framework.
Browser events can be fired on user interaction with webpage like on click of a button or on drop-down value selection change.
You can declare these events in markup and handle in controller file.
Using Controller File To Handle Browser Events
Every method in the controller file accepts three parameters which are being supplied by the framework itself. These parameters are:
component—The component to which the controller belongs.
event—The event that the action is handling.
Put functions that you want to reuse in the component’s helper.js. These functions can be called from multiple controller/helper functions.
Helper file helps in moving heavy lifting from the client-side controller. Helper functions also enable specialization of tasks, such as processing data and firing server-side actions.
Helper methods cannot be called directly from component markup and must be invoked from controller, renderer or helper file.
Update CarSearchForm Component
Lightning Component Development Day3 - App, Attributes, Looping, Conditional Markup, Handling Events
Test your knowledge