Skip to content

[Live] Adding an example of a norender model with a button to trigger the render #1574

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 5, 2024
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
23 changes: 23 additions & 0 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,29 @@ it won't, yet, make an Ajax call to re-render the component. Whenever
the next re-render *does* happen, the updated ``max`` value will be
used.

This can be useful along with a button that triggers a render on click:

.. code-block:: html+twig

<input data-model="norender|coupon">
<button data-action="live#$render">Apply</button>

Forcing a Re-Render Explicitly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In some cases, you might want to force a component re-render explicitly. For
example, consider a checkout component that provides a coupon input that must
only be used when clicking on the associated "Apply coupon" button:

.. code-block:: html+twig

<input data-model="norender|coupon">
<button data-action="live#$render">Apply coupon</button>

The ``norender`` option on the input ensures that the component won't re-render
when this input changes. The ``live#$render`` action is a special built-in action
that triggers a re-render.

.. _name-attribute-model:

Using name="" instead of data-model
Expand Down