Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Accredited B2B Commerce Developer Professional (AP-202) Exam - Topic 2 Question 77 Discussion

Posted by Casey on Apr 08, 2025 at 01:56 AM

A developer has made a component with a lightning combobox in the follow! markup. To handle changes on the combobox, what should replace ?

Suggested Answer: D

To handle changes on the combobox, the developer should replace <CHANGE EVENT> with {handleChange}. The handleChange is a function that is defined in the JavaScript file of the Lightning web component and is invoked when the value of the combobox changes. The developer can use this function to perform custom logic or actions based on the selected value of the combobox, such as updating other components or properties, calling Apex methods or services, or firing events. The developer can use the onchange attribute to bind the handleChange function to the combobox element in the HTML file of the Lightning web component. The onchange attribute is an HTML attribute that specifies a function to be executed when the value of an element changes. {event:handleChange} is not a valid way to handle changes on the combobox, as it is not a valid syntax for binding a function to an element. javascript:void(0);handleChange(); is not a valid way either, as it is not a valid syntax for binding a function to an element. {handleChange()} is not a valid way either, as it is not a valid syntax for binding a function to an element. Salesforce Reference: Lightning Web Components Developer Guide: Handle Events, Lightning Web Components Developer Guide: Communicate with Properties, Lightning Web Components Developer Guide: lightning-combobox


Get Premium Salesforce Accredited B2B Commerce Developer Professional (AP-202) Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
34 comments · newest first
ER
Erick 10 months ago
I feel like {handleChange} is a common mistake people make.
DA
Dallas 11 months ago
Not so sure about that, could be {handleChange} too.
NE
Nettie 11 months ago
I think it should be {event:handleChange}.
SH
Shanda 11 months ago
Wait, why is {handleChange()} even an option? Seems off.
HA
Hassie 11 months ago
Totally agree, that's the correct syntax!
KA
Katy 11 months ago
I remember that for event handlers, we usually use the event object. So I'm leaning towards A, but I could be wrong about the syntax.
BR
Brittni 12 months ago
I'm a bit confused about whether to use the parentheses or not. I thought handleChange should be called with parentheses, so maybe C is right?
LE
Leana 12 months ago
I feel like I've seen a similar question before, and I think it was about using the correct syntax for event handlers. Maybe it's A?
FE
Felix 1 year ago
I think the answer might be D, but I'm not completely sure if it needs the curly braces. I remember something about event handling in Lightning components.
LI
Ligia 1 year ago
Okay, I think I've got this. The correct answer is to use the {event:handleChange} syntax to bind the change event to the handleChange method in the component's JavaScript. I'll select that option and move on.
IL
Ilda 1 year ago
I'm a bit unsure about this one. The options seem similar, and I want to make sure I understand the correct syntax for handling changes in a Lightning Combobox. I'll need to review the documentation to refresh my memory.
JE
Jenise 1 year ago
Ah, I see. This is testing our knowledge of Lightning component event handling. I'm pretty confident I know the right approach, but I'll double-check the options to make sure I don't miss anything.
SI
Simona 1 year ago
Okay, let me think this through. The question is asking what should replace the in the markup, so I need to consider the different options and how they would work in the context of a Lightning Combobox.
CA
Carylon 1 year ago
Hmm, this looks like a straightforward question about handling changes in a Lightning Combobox. I'll need to carefully review the options and think about the correct event handler syntax.
RE
Reiko 1 year ago
Wait, is this a trick question? What if the developer is a time-traveling wizard who uses {event:handleChange} to control the space-time continuum?
PA
Pamela 1 year ago
↳ replying to Reiko
C) {handleChange()}
RE
Rebecka 1 year ago
↳ replying to Reiko
B) javascript:void(0);handleChange();
LE
Leandro 1 year ago
↳ replying to Reiko
A) {event:handleChange}
FL
Fletcher 1 year ago
Hmm, I'm not sure about this one. Maybe the answer is C? {handleChange()} seems more intuitive to me.
LA
Lauryn 1 year ago
↳ replying to Fletcher
I agree with you, C) {handleChange()} makes more sense to me.
RH
Rhea 1 year ago
↳ replying to Fletcher
I'm leaning towards B) javascript:void(0);handleChange();
TY
Tyisha 1 year ago
↳ replying to Fletcher
No, I believe it's D) {handleChange}
PA
Pa 1 year ago
↳ replying to Fletcher
I think the answer is A) {event:handleChange}
IS
Isaiah 1 year ago
Option B looks a bit sketchy. Shouldn't we be using event handlers instead of JavaScript links?
SH
Shayne 1 year ago
↳ replying to Isaiah
Yeah, option B) javascript:void(0);handleChange(); does seem a bit risky. Let's go with option A).
MA
Margurite 1 year ago
↳ replying to Isaiah
I think option A) {event:handleChange} would be the correct choice for handling the combobox changes.
JE
Jerilyn 1 year ago
↳ replying to Isaiah
I agree, using event handlers is definitely the better practice.
TE
Tequila 2 years ago
I think the correct answer is D. {handleChange} because that's the standard way to handle changes in a Lightning combobox.
TY
Ty 1 year ago
↳ replying to Tequila
I believe it's C) {handleChange()} as that seems like the right syntax to handle changes.
AD
Adelle 1 year ago
↳ replying to Tequila
I'm not sure, but I think it could be A) {event:handleChange}
GL
Glendora 1 year ago
↳ replying to Tequila
I think the correct answer is D. {handleChange} because that's the standard way to handle changes in a Lightning combobox.
PA
Paris 2 years ago
I'm not sure, but I think C) {handleChange()} could also be a valid option
AY
Ayesha 2 years ago
I agree with Junita, A) {event:handleChange} makes sense to handle the comAyeshaox changes
JU
Junita 2 years ago
I think the answer is A) {event:handleChange}
0/2000 characters

Save Cancel