Skip to content

[Live] Clarifying problem with external JS and the work-around #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2023
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
16 changes: 16 additions & 0 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,20 @@ commonly used. You can also use the normal modifiers, like
``data-model="on(change)|*"`` to, for example, only send
model updates for the ``change`` event of each field inside.

Model Updates don't work when External JavaScript Changes a Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suppose you use a JavaScript library that sets the value of a field
*for* you: for example a "date picker" library that hides
the native ``<input data-model="publishAt">`` field and sets it
behind-the-scenes when the user selects a date.

In this case, the model (e.g. ``publishAt``) will probably *not*
update correctly because JavaScript doesn't trigger the normal
``change`` event. To fix this, you'll need to "hook" into the
JavaScript library and set the model directly (or trigger a
``change`` event on the ``data-model`` field). See :ref:`working-in-javascript`.

LiveProp for Entities & More Complex Data
-----------------------------------------

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

.. _working-in-javascript:

Working with the Component in JavaScript
----------------------------------------

Expand Down