Domma Reactive User Manual

Forms and inputs

Updated by Darryl Waterhouse on 17 October 2026 3 min read

data-model

Two-way. The expression must be a settable path - a bare name, or a member chain ending in one:

<input data-model="query">
<input data-model="user.email">
<input data-model="rows[i]">

At write time the object part is evaluated and the last step is used as a key, so the write lands where the read came from. Anything that is not a path (a comparison, a helper call, $data/$root/$parent/$index) logs one warning and writes nothing, because a binding you cannot write through is not two-way. __proto__, constructor and prototype are refused as keys, in every form, including a[k] where k holds one of them at runtime.

There is no observable-unwrapping magic. A tracking proxy is written as data-model="name"; a standalone observable is written as data-model="count.value", which is the same .value you read it through. Both are ordinary property assignments:

const count = observable(0);
compile('<input type="number" data-model="count.value">', {count}, host);
Control Property Listened events
checkbox checked (boolean) change
radio checked, against its value change
select[multiple] an array of selected values change
select value change
number, range value coerced to a Number, empty → null input, change
everything else value input, change

An unchecked radio writes nothing, so the group's value is not cleared by the sibling that lost the selection. The data → DOM direction writes only when the value actually differs, so re-rendering while someone is typing does not move their caret.

data-options

Populate a <select> from a collection.

<select data-options="cities" data-model="chosen"></select>

<select data-options="people"
        data-options-text="first + ' ' + last"
        data-options-value="id"
        data-options-caption="'Anyone'"
        data-model="assignee"></select>
Attribute Meaning
data-options the collection
data-options-text the label - an expression against the item; defaults to the item
data-options-value the value - likewise
data-options-caption a leading option with an empty value

{{#each cities}}<option>{{.}}</option>{{/each}} produces the same markup. What it does not produce is the selection: rebuilding a select's options resets it, and the selection lives on the select rather than on any item, so a keyed list has nothing to preserve it with. This binding rebuilds and puts the selection back - which is the only part you cannot easily write yourself.

The three companions are expressions evaluated in the item's own context, so $index, $parent and $root all resolve, and a label can be computed. Knockout takes a property name here, which cannot express that. The cost is that a literal caption needs its quotes: data-options-caption="'Anyone'".

Values need not be strings. An <option>'s value is always a string, so when the resolved value is not one the real value is kept alongside it and data-model reads back the object or the number that went in - not "[object Object]". With no data-options-value at all, the value is the item, matched by identity.

Order does not matter, and neither does timing: <select data-model="chosen" data-options="cities"> works, and so does a list that arrives from a fetch long afterwards. A value the model asked for while no option carried it is remembered and applied by the rebuild that brings it.

data-focus

Two-way, between a value and focus. Knockout calls this hasFocus.

<input data-model="title" data-focus="editingTitle">

Setting editingTitle to true moves focus into the field; the user tabbing in sets it to true; blurring sets it to false. Both directions earn their place - the first is how a view model puts the caret in the field it has just revealed, without reaching for a DOM node; the second is how it knows where the user is without wiring up listeners.

Unlike data-model, an expression it cannot write through is not fatal: data-focus="isEditing && !isSaving" is a sensible way to drive focus from derived state, so the value → focus direction keeps working and only the write-back warns.