ExamGecko
Question list
Search
Search

List of questions

Search

Question 250 - Certified B2B Commerce Administrator discussion

Report
Export

In which two ways can events fired from Lightning web components be handled? 02m 05s

A.
Programmatically adding event listeners
Answers
A.
Programmatically adding event listeners
B.
Adding callbacks to components
Answers
B.
Adding callbacks to components
C.
Listening for all possible events at the document root
Answers
C.
Listening for all possible events at the document root
D.
Attaching handlers to DOM elements
Answers
D.
Attaching handlers to DOM elements
Suggested answer: A, D

Explanation:

Events fired from Lightning web components can be handled in two ways: programmatically adding event listeners or attaching handlers to DOM elements. Programmatically adding event listeners involves using the addEventListener method on the component or a specific element to register a callback function that executes when the event occurs.This method gives the developer more control over the event handling logic, such as adding conditional statements, removing listeners, or using custom events3. Attaching handlers to DOM elements involves using the on directive in the component's HTML template to bind an event handler to a specific element.This method is simpler and more declarative, but it only works for standard DOM events4.Reference:3: Handle Events Programmatically - Trailhead5,4: Handle Events Declaratively - Trailhead6

asked 23/09/2024
Velmurugan P
42 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first