Skip to content

Commit bdadfd2

Browse files
committed
minor #703 [Live] Clarifying problem with external JS and the work-around (weaverryan)
This PR was merged into the 2.x branch. Discussion ---------- [Live] Clarifying problem with external JS and the work-around | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Tickets | See #694 | License | MIT Commits ------- c90ea5e [Live] Clarifying problem with external JS and the work-around
2 parents 751d113 + c90ea5e commit bdadfd2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,20 @@ commonly used. You can also use the normal modifiers, like
391391
``data-model="on(change)|*"`` to, for example, only send
392392
model updates for the ``change`` event of each field inside.
393393

394+
Model Updates don't work when External JavaScript Changes a Field
395+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396+
397+
Suppose you use a JavaScript library that sets the value of a field
398+
*for* you: for example a "date picker" library that hides
399+
the native ``<input data-model="publishAt">`` field and sets it
400+
behind-the-scenes when the user selects a date.
401+
402+
In this case, the model (e.g. ``publishAt``) will probably *not*
403+
update correctly because JavaScript doesn't trigger the normal
404+
``change`` event. To fix this, you'll need to "hook" into the
405+
JavaScript library and set the model directly (or trigger a
406+
``change`` event on the ``data-model`` field). See :ref:`working-in-javascript`.
407+
394408
LiveProp for Entities & More Complex Data
395409
-----------------------------------------
396410

@@ -527,6 +541,8 @@ live property on your component to the value ``edit``. The
527541
``data-action="live#update"`` is Stimulus code that triggers
528542
the update.
529543

544+
.. _working-in-javascript:
545+
530546
Working with the Component in JavaScript
531547
----------------------------------------
532548

0 commit comments

Comments
 (0)