ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 30 - AD0-E720 discussion

Report
Export

An Adobe Commerce developer wants to apply a knockout binding to a to run a function, onClick(), when it's clicked. Which two solutions would the developer use to achieve this? (Choose two.)

A.
<x/div> B <!-- ko click: 'onClick' --> <!-- /ko -->
Answers
A.
<x/div> B <!-- ko click: 'onClick' --> <!-- /ko -->
B.
Answers
B.
C.
Answers
C.
Suggested answer: A, C

Explanation:

To apply a knockout binding to a to run a function, onClick(), when it's clicked, the developer can use either of the following solutions:

A) : This solution will use the click binding to execute the onClick() function as an expression when the is clicked. The function will be called with the current binding context as the first parameter and the event object as the second parameter.

C) : This solution will use the click binding to execute the onClick function as a reference when the is clicked. The function will be called with the current binding context as the first parameter and the event object as the second parameter.

The following solutions are not valid and will not work:

B) <!-- ko click: 'onClick' --><!-- /ko -->: This solution will use the virtual element syntax to apply the click binding, but it will pass a string literal instead of a function expression or reference. This will cause an error, as the click binding expects a function value.

D) : This solution will use a custom attribute instead of a data-bind attribute to apply the click binding. This is not supported by knockout and will not have any effect.

asked 02/10/2024
KHALID ALSHAHRANI
46 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first