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

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? no
New feature? no
Issues Fix #1569
License MIT

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Mar 2, 2024
@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 4, 2024

Thanks Ryan!

I like that the new doc addition is concise ... but as a newcomer, I might need something more detailed to understand the reasoning for this and the special action used to trigger the re-render.

If you agree, I'd add the following section after the existing Deferring a Re-Render Until Later section:

Forcing a Re-Render Explictly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

@weaverryan weaverryan force-pushed the live-docs-render-on-click branch from 67a0daf to 8ac6311 Compare March 5, 2024 16:47
@weaverryan weaverryan force-pushed the live-docs-render-on-click branch from 8ac6311 to cf7545b Compare March 5, 2024 16:50
@weaverryan weaverryan merged commit 5d2691d into symfony:2.x Mar 5, 2024
@weaverryan
Copy link
Member Author

I like it - thanks Javier!

@weaverryan weaverryan deleted the live-docs-render-on-click branch March 5, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explicit re-render of a field when clicking a button
4 participants