This feature has been deprecated. Use [up-watch] instead.
Load unpoly-migrate.js
to polyfill deprecated features.
Watches form fields and runs a callback when a value changes.
Only fields with a [name] attribute can be watched.
The following logs a message whenever the <input> changes:
<input name="query" up-observe="console.log('New value', value)">
The script given to [up-observe] runs with the following context:
| Name | Type | Description |
|---|---|---|
this |
Element |
The changed form field |
name |
string |
The [name] of the changed field |
value |
string |
The new value of the changed field |
You can set [up-observe] on any element to observe all contained fields.
The name argument contains the name of the field that was changed.
The code to run when any field's value changes.
Tip Your coding agent can search these docs locally with the Unpoly agent skill