Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit f6a7753

Browse files
authored
Merge pull request #8609 from DenisSaltanahmedov/improvement-add-js-init-info
#8106 Clarify JS init component key
2 parents 34680a2 + 815507f commit f6a7753

File tree

1 file changed

+14
-0
lines changed
  • src/guides/v2.3/javascript-dev-guide/javascript

1 file changed

+14
-0
lines changed

src/guides/v2.3/javascript-dev-guide/javascript/js_init.md

+14
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ On DOM ready, the `data-mage-init` attribute is parsed to extract component name
111111
};
112112
```
113113

114+
Where `<component_name>` is a native Magento JS component, for example: `menu`, `collapsible`, `tooltip` ...
115+
116+
```html
117+
<nav data-mage-init='{"tooltip": {"content": "<?= /* @noEscape */ $content ?>"}}'></nav>
118+
```
119+
120+
Or a custom JS component, implemented with a component path: `Vendor_Module/js/component`, or as an alias declared in `requirejs-config.js`.
121+
122+
```html
123+
<nav data-mage-init='{"Vendor_Module/js/component": {"status":"<?= /* @noEscape */ $block->getStatus(); ?>"}}'></nav>
124+
```
125+
126+
Read more about [locate JS components](https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_debug.html).
127+
114128
- If a function is returned, the initializer passes the <code>config</code> and <code>element</code> values to this function. For example:
115129

116130
```javascript

0 commit comments

Comments
 (0)