LiveView Form Bindings
Explore how to use Phoenix LiveView form bindings to manage real-time form submissions and validations. Learn to customize submission behavior and apply debounce to improve user experience and reduce backend load.
We'll cover the following...
We already know that LiveView uses annotations called bindings to tie live views to events using platform JavaScript. This lesson demonstrated the use of two form bindings: phx-submit for submitting a form and phx-change for form validations.
LiveView also offers bindings to control how often, and under what circumstances, LiveView JavaScript emits form events. These bindings can disable form submission and debounce, or slow down, form change events. These bindings help you provide sane user experiences on the frontend and ensure less unnecessary load on the backend.
Let’s take a brief look at these bindings and how they work.
How to submit and disable a form
By default, binding phx-submit events cause three things to occur on the client:
- The