ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 31 - AD0-E720 discussion

Report
Export

An Adobe commerce developer wants to initialize a JavaScript component using a data attribute. Which option would initialize the JavaScript component?

A.
<nav data-bind='{'<component_name>': {...}}'></nav>
Answers
A.
<nav data-bind='{'<component_name>': {...}}'></nav>
B.
<nav data-init='{'<component_name>': {...}}'></nav>
Answers
B.
<nav data-init='{'<component_name>': {...}}'></nav>
C.
<nav data-mage-init='{'<component_name>': {...}}'></nav>
Answers
C.
<nav data-mage-init='{'<component_name>': {...}}'></nav>
Suggested answer: C

Explanation:

To initialize a JavaScript component using a data attribute, the developer should use the data-mage-init attribute. This attribute allows the developer to specify the name and configuration of the component in a JSON format. For example:

<nav data-mage-init='{''Vendor_Module/js/nav'': {''option1'': ''value1'', ''option2'': ''value2''}}'></nav>

This will initialize the nav component from the Vendor_Module/js/nav file with the given options. The data-bind and data-init attributes are not valid and will not work, as they are not supported by Magento.

Reference: [JavaScript initialization], [data-mage-init]

asked 02/10/2024
Andrew Dobie
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first