pub struct HtmlElement<C> { /* private fields */ }Expand description
A Generic html node with a given name.
Implementations§
Source§impl<C> HtmlElement<C>
impl<C> HtmlElement<C>
Sourcepub fn new(tag: &'static str) -> Self
pub fn new(tag: &'static str) -> Self
Create a new html element with the specific tag
All non-deprecated html elements have a helper function in this module
Sourcepub fn on<E: Event>(self, function: impl EventHandler<C, E::JsEvent>) -> Self
pub fn on<E: Event>(self, function: impl EventHandler<C, E::JsEvent>) -> Self
Register a event handler for this element.
The event handler is a closure taking a mutable reference to S<Self>.
e::button().on("click", |ctx: &mut S<Self>| {
*ctx.some_value += 1;
})For more information see Reactivity in the book.
Sourcepub fn child<E: Element<C> + 'static>(self, child: E) -> Self
pub fn child<E: Element<C> + 'static>(self, child: E) -> Self
Push a child to this element. This accepts any valid element including closures.
e::div()
.child(e::h1().text("Wow!"))
.child(|ctx: &S<Self>| {
if *ctx.toggle {
"Hello"
} else {
"World"
}
})Sourcepub fn attr(self, key: &'static str, value: impl ToAttribute<C>) -> Self
pub fn attr(self, key: &'static str, value: impl ToAttribute<C>) -> Self
Add a attribute to the node.
See Html Nodes in the book for the schematics of the various valid attribute types.
Trait Implementations§
impl<C: ComponentData> Element<C> for HtmlElement<C>
Auto Trait Implementations§
impl<C> Freeze for HtmlElement<C>
impl<C> !RefUnwindSafe for HtmlElement<C>
impl<C> !Send for HtmlElement<C>
impl<C> !Sync for HtmlElement<C>
impl<C> Unpin for HtmlElement<C>
impl<C> !UnwindSafe for HtmlElement<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more