diff options
author | GeoSot <geo.sotis@gmail.com> | 2022-04-21 21:41:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 21:41:43 +0300 |
commit | 584600bda36ac13ea325617783216d6c6a331c08 (patch) | |
tree | 053f97d3e8401864aca9c0b8e180a3d2c089b4be /site/layouts | |
parent | 01cffa682249965eafa581058dd993853d82b3c4 (diff) |
Manipulator: Add JSON parse support (#35077)
Support parsing JSON from each component's main element using the `data-bs-config` attribute.
The `bs-config` attribute will be reserved and omitted during `getDataAttributes` parsing.
With this commit, every component, will create its config object, using:
* defaults
* data-bs-config
* the rest of data attributes
* configuration object given during instance initialization
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Co-authored-by: Mark Otto <markd.otto@gmail.com>
Co-authored-by: Mark Otto <markdotto@gmail.com>
Diffstat (limited to 'site/layouts')
-rw-r--r-- | site/layouts/partials/js-data-attributes.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/site/layouts/partials/js-data-attributes.md b/site/layouts/partials/js-data-attributes.md new file mode 100644 index 0000000000..c188652f06 --- /dev/null +++ b/site/layouts/partials/js-data-attributes.md @@ -0,0 +1,3 @@ +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-bs-`, as in `data-bs-animation=""`. Make sure to change the case type of the option name from camelCase to kebab-case when passing the options via data attributes. For example, use `data-bs-custom-class="beautifier"` instead of `data-bs-customClass="beautifier"`. + +As of Bootstrap 5.2.0, all components support an **experimental** reserved data attribute `data-bs-config` that can house simple component configuration as a JSON string. When an element has `data-bs-config='{"delay":0, "title":123}'` and `data-bs-title="456"` attributes, the final `title` value will be `456` and the separate data attributes will override values given on `data-bs-config`. In addition, existing data attributes are able to house JSON values like `data-bs-delay='{"show":0,"hide":150}'`. |