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 would run a log whenever the <input> changes:
<input name="query" up-observe="console.log('New value', value)">
The script given to [up-watch] runs with the following context:
| Name | Type | Description |
|---|---|---|
this |
Element |
The changed form field |
name |
Element |
The [name] of the changed field |
value |
string |
The new value of the changed field |
You can set [up-watch] 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.