docs
/
Studio Manager

Effects and formats

What runs after an action, and how bound values are rendered.

Two small vocabularies do a lot of work: effects decide what happens after an action, formats decide how a bound value renders.

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 | close-dialog | refresh"

Each entry is verb or verb:argument.

EffectSyntaxWhat it does
navigatenavigate:<url>Go to a URL
notifynotify:<message>Show an info toast
notify-errornotify-error:<message>Show an error toast
close-dialogclose-dialogClose the nearest open dialog or drawer
open-dialogopen-dialog:#dialogIdOpen a dialog by selector
reloadreloadHard reload the page
refreshrefresh or refresh:#idRe-run every data-source on the page, or just one
set-stateset-state:path=valueWrite into appmint.state
reset-formreset-formReset the form the action came from
focusfocus:#selFocus an element

refresh is usually what you want after a write — it re-runs the sources so lists reflect the change without a page reload.

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.

FormatRenders as
currencyCurrency — takes a currency option, ISO code, default USD
numberLocale-formatted number
percentPercentage
dateLocale date
datetimeLocale date and time
parenthesesWraps positive numbers in parentheses
uppercaseUPPERCASE
lowercaselowercase
capitalizeCapitalized

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.