Skip to content

Commit cd84f5a

Browse files
committed
minor #1538 [Doc] Add more examples of adding attributes in Live Components (javiereguiluz)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Doc] Add more examples of adding attributes in Live Components | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | - | License | MIT Note: I tried this in a Symfony app and it didn't work ... so I'm opening this PR to ask you if this should work or if `addAttribute()` is only for empty attributes that don't define a value. Thanks! Commits ------- a6f2fe6 [Doc] Add more examples of adding attributes in Live Components
2 parents ad25472 + a6f2fe6 commit cd84f5a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,16 +929,22 @@ a class:
929929
<div data-loading="removeClass(opacity-50)">...</div>
930930

931931
<!-- add multiple classes when loading -->
932-
<div data-loading="addClass(opacity-50 disabled)">...</div>
932+
<div data-loading="addClass(opacity-50 text-muted)">...</div>
933933

934-
Sometimes you may want to add or remove an attribute when loading. That
934+
Sometimes you may want to add or remove an HTML attribute when loading. That
935935
can be accomplished with ``addAttribute`` or ``removeAttribute``:
936936

937937
.. code-block:: html+twig
938938

939939
<!-- add the "disabled" attribute when loading -->
940940
<div data-loading="addAttribute(disabled)">...</div>
941941

942+
.. caution::
943+
944+
The ``addAttribute()`` and ``removeAttribute()`` functions only work with
945+
empty HTML attributes (``disabled``, ``readonly``, ``required``, etc.) and
946+
not with attributes that define their values (e.g. this won't work: ``addAttribute(style='color: red')``).
947+
942948
You can also combine any number of directives by separating them with a
943949
space:
944950

0 commit comments

Comments
 (0)