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

#8106 Clarify JS init component key #8609

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/guides/v2.3/javascript-dev-guide/javascript/js_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ On DOM ready, the `data-mage-init` attribute is parsed to extract component name
};
```

Where `<component_name>` is a native Magento JS component, for example: `menu`, `collapsible`, `tooltip` ...

```html
<nav data-mage-init='{"tooltip": {"content": "<?= /* @noEscape */ $content ?>"}}'></nav>
```

Or a custom JS component, implemented with a component path: `Vendor_Module/js/component`, or as an alias declared in `requirejs-config.js`.

```html
<nav data-mage-init='{"Vendor_Module/js/component": {"status":"<?= /* @noEscape */ $block->getStatus(); ?>"}}'></nav>
```

Read more about [locate JS components](https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_debug.html).

- If a function is returned, the initializer passes the <code>config</code> and <code>element</code> values to this function. For example:

```javascript
Expand Down