日本語

El

El<S> is an HTML element on a page whose signals are S. Its methods return the element, so a tree is one expression.

Content and attributes

ItemSummary
childAppends a child element, text, or template.
childrenAppends several children. An Option counts as zero or one child.
textAppends static text.
attrSets a plain attribute.
hrefSets the element's href: a link to a page the router serves, or a SafeUrl for an address it does not.
srcSets the element's src, the address of the image, frame, or script it loads, as El::href sets href.
idSets the element's id.
classAdds a static class.
cssAdds the declarations of style as atomic classes.
node_refAttaches node_ref, so its statements act on this element.
foreignLeaves this element's attributes and children to a script, and names it node_ref.
renderRenders the element and its children to an HTML string.

Bindings

Each binding takes an expression over the signals, and the runtime updates the element with the expression's value whenever a signal changes.

ItemSummary
bind_textReplaces the element's text with text, kept up to date as signals change.
showShows the element only while when is true.
bind_attrKeeps attribute name equal to value as signals change.
attr_whenSets the boolean attribute name, such as disabled, while when is true.
disabledDisables the control while when is true, through disabled.
class_whenAdds class while when is true.
css_whenAdds the declarations of style while when is true.
css_matchAdds the style of the case whose value value equals.
bind_styleKeeps the CSS property property equal to value as signals change.
bind_tokenKeeps token equal to value on this element and those inside it.
bindBinds a form control to a signal in both directions.
bind_checkedKeeps a checkbox's checked state equal to when, in one direction.
bind_radioMakes this radio button set signal to value when checked.
bind_selectFills this <select> with options and binds it to signal.

Events

ItemSummary
onRuns stmt on event. When on is called twice for the same event, the second statement runs after the first.
on_clickRuns stmt on click.
on_double_clickRuns stmt on double click.
on_inputRuns stmt on every edit of a text field.
on_changeRuns stmt on change.
on_submitRuns stmt when a form is submitted, after preventDefault.
on_blurRuns stmt when focus leaves the element.
on_visibleRuns stmt each time the element comes into the viewport.
on_keyRuns stmt when shortcut is pressed while focus is in this element.
on_debouncedRuns stmt once event has stopped firing for quiet.
on_customRuns the statement handle builds whenever event reaches this element.

Lifecycle and focus

ItemSummary
on_loadRuns stmt once when the element is added to the document.
on_intervalRuns stmt every period while the element is in the document.
on_timeoutRuns stmt once, delay after the element is added to the document, if it is still in it then.
effectRuns stmt when the element is added to the document and whenever a signal stmt reads changes.
on_signal_changeRuns stmt whenever signal, or any field inside it, changes.
roving_focusMoves focus between the items inside this element on the arrow keys, Home, and End.
active_descendantTracks the active option of listbox in active on the up and down arrows.