Struct silkenweb_dom::ElementBuilder[][src]

pub struct ElementBuilder { /* fields omitted */ }

Build an HTML element.

Implementations

impl ElementBuilder[src]

pub fn new(tag: impl AsRef<str>) -> Self[src]

pub fn attribute<T>(
    self,
    name: impl AsRef<str>,
    value: impl AttributeValue<T>
) -> Self
[src]

Set an attribute. Attribute values can be reactive.

pub fn child(self, child: impl Into<Element>) -> Self[src]

Add a child element after existing children. The child element can be reactive.

pub fn text(self, child: impl Text) -> Self[src]

Add a text node after existing children. The text node can be reactive.

pub fn effect<T>(self, child: impl Effect<T>) -> Self[src]

Apply an effect after the next render. For example, to set the focus of an element:

element.effect(|elem: &HtmlInputElement| elem.focus().unwrap());

Effects can be reactive. For example, to set the visibibilty of an item based on a hidden boolean signal:

let hidden = Signal::new(false);
let is_hidden = hidden.read();

element.effect(is_hidden.map(|&hidden| move |elem: &HtmlInputElement| elem.set_hidden(hidden)));

pub fn on(self, name: &'static str, f: impl 'static + FnMut(JsValue)) -> Self[src]

Register an event handler.

name is the name of the event. See the MDN Events page for a list.

f is the callback when the event fires and will be passed the javascript Event object.

Trait Implementations

impl Builder for ElementBuilder[src]

type Target = Element

impl DomElement for ElementBuilder[src]

type Target = Element

impl From<ElementBuilder> for Element[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.