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
| Item | Summary |
|---|---|
child | Appends a child element, text, or template. |
children | Appends several children. An Option counts as zero or one child. |
text | Appends static text. |
attr | Sets a plain attribute. |
href | Sets the element's href: a link to a page the router serves, or a SafeUrl for an address it does not. |
src | Sets the element's src, the address of the image, frame, or script it loads, as El::href sets href. |
id | Sets the element's id. |
class | Adds a static class. |
css | Adds the declarations of style as atomic classes. |
node_ref | Attaches node_ref, so its statements act on this element. |
foreign | Leaves this element's attributes and children to a script, and names it node_ref. |
render | Renders 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.
| Item | Summary |
|---|---|
bind_text | Replaces the element's text with text, kept up to date as signals change. |
show | Shows the element only while when is true. |
bind_attr | Keeps attribute name equal to value as signals change. |
attr_when | Sets the boolean attribute name, such as disabled, while when is true. |
disabled | Disables the control while when is true, through disabled. |
class_when | Adds class while when is true. |
css_when | Adds the declarations of style while when is true. |
css_match | Adds the style of the case whose value value equals. |
bind_style | Keeps the CSS property property equal to value as signals change. |
bind_token | Keeps token equal to value on this element and those inside it. |
bind | Binds a form control to a signal in both directions. |
bind_checked | Keeps a checkbox's checked state equal to when, in one direction. |
bind_radio | Makes this radio button set signal to value when checked. |
bind_select | Fills this <select> with options and binds it to signal. |
Events
| Item | Summary |
|---|---|
on | Runs stmt on event. When on is called twice for the same event, the second statement runs after the first. |
on_click | Runs stmt on click. |
on_double_click | Runs stmt on double click. |
on_input | Runs stmt on every edit of a text field. |
on_change | Runs stmt on change. |
on_submit | Runs stmt when a form is submitted, after preventDefault. |
on_blur | Runs stmt when focus leaves the element. |
on_visible | Runs stmt each time the element comes into the viewport. |
on_key | Runs stmt when shortcut is pressed while focus is in this element. |
on_debounced | Runs stmt once event has stopped firing for quiet. |
on_custom | Runs the statement handle builds whenever event reaches this element. |
Lifecycle and focus
| Item | Summary |
|---|---|
on_load | Runs stmt once when the element is added to the document. |
on_interval | Runs stmt every period while the element is in the document. |
on_timeout | Runs stmt once, delay after the element is added to the document, if it is still in it then. |
effect | Runs stmt when the element is added to the document and whenever a signal stmt reads changes. |
on_signal_change | Runs stmt whenever signal, or any field inside it, changes. |
roving_focus | Moves focus between the items inside this element on the arrow keys, Home, and End. |
active_descendant | Tracks the active option of listbox in active on the up and down arrows. |