[up-observe]
HTML attribute
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.
Example
The following logs a message whenever the <input> changes:
<input name="query" up-observe="console.log('New value', value)">
Callback context
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 |
Watching multiple fields
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.
Modifying attributes
up-observe
required
The code to run when any field's value changes.