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

Commit cbf7769

Browse files
#8106 Update js_init.md
Adding more information about component key in the Declarative notation section.
1 parent 97e10bd commit cbf7769

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

Lines changed: 14 additions & 0 deletions
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>` 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, can be component path `Vendor_Module/js/component` or alias declareted in `requirejs-config.js`.
121+
122+
```html
123+
<nav data-mage-init='{"Vendor_Module/js/component": {"status":"<?= /* @noEscape */ $block->getStatus(); ?>"}}'></nav>
124+
```
125+
126+
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)