Two small vocabularies do a lot of work: effects decide what happens after an action, formats decide how a bound value renders.
Video tutorials for this topic
Effects
An effect chain runs after an action resolves. data-on-success runs on success, data-on-error on failure.
Chains are pipe-separated and run left to right:
data-on-success="notify:Saved | reset-form | refresh:#my-list"Each entry is verb or verb:argument.
| Effect | Syntax | What it does |
|---|---|---|
navigate | navigate:<url> | Go to a URL |
notify | notify:<message> | Show an info toast |
notify-error | notify-error:<message> | Show an error toast |
close-dialog | close-dialog | Remove the open attribute from the nearest open dialog or drawer — see the warning below |
open-dialog | open-dialog:#dialogId | Set the open attribute on the element the selector matches — see the warning below |
reload | reload | Hard reload the page |
refresh | refresh:#id | Re-run that element's data-source (or data-loop) |
set-state | set-state:path=value | Write into appmint.state |
reset-form | reset-form | Reset the form the action came from |
focus | focus:#sel | Focus an element |
refresh:#id is usually what you want after a write — it re-runs that source so the list reflects the change without a page reload. Always give it the target: a bare refresh sends its signal to the window, which no source listens on, so nothing re-runs.
open-dialog and close-dialog do not open or close a wm-dialog or wm-drawer. They only set or remove its open attribute, and those elements read open once, when they start. Open and close them with the ui.dialog / ui.drawer action, as in Custom elements.
Worked example
<form data-action="ticket.create"
data-payload="form"
data-on-success="notify:Ticket opened | reset-form | refresh:#my-tickets"
data-on-error="notify-error:Could not open ticket">
<input name="subject" required>
<textarea name="body"></textarea>
<button type="submit">Open ticket</button>
</form>Submitting serializes the form, creates the ticket, toasts, clears the form, and refreshes only the ticket list.
Formats
data-format renders a bound value for display. The underlying value is untouched.
| Format | Renders as |
|---|---|
currency | Currency — takes a currency option, ISO code, default USD |
number | Locale-formatted number |
percent | Percentage |
date | Locale date |
datetime | Locale date and time |
parentheses | Wraps positive numbers in parentheses |
uppercase | UPPERCASE |
lowercase | lowercase |
capitalize | Capitalized |
Format options
Options are passed as separate attributes, named data-format-opt-<option>:
<span data-bind="data.price"
data-format="currency"
data-format-opt-currency="EUR"></span>Only currency takes an option today — the ISO currency code.
