[−][src]Struct yew::html::NodeRef
Wrapped Node reference for later use in Component lifecycle methods.
Example
Focus an <input>
element on mount.
#[cfg(feature = "std_web")] use stdweb::web::{html_element::InputElement, IHtmlElement}; #[cfg(feature = "web_sys")] use web_sys::HtmlInputElement as InputElement; pub struct Input { node_ref: NodeRef, } impl Component for Input { type Message = (); type Properties = (); fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { Input { node_ref: NodeRef::default(), } } fn mounted(&mut self) -> ShouldRender { if let Some(input) = self.node_ref.cast::<InputElement>() { input.focus(); } false } fn update(&mut self, _: Self::Message) -> ShouldRender { false } fn view(&self) -> Html { html! { <input ref=self.node_ref.clone() type="text" /> } } }
Methods
impl NodeRef
[src]
pub fn get(&self) -> Option<Node>
[src]
Get the wrapped Node reference if it exists
pub fn cast<INTO: AsRef<Node> + From<JsValue>>(&self) -> Option<INTO>
[src]
Try converting the node reference into another form
Trait Implementations
impl Clone for NodeRef
[src]
impl Debug for NodeRef
[src]
impl Default for NodeRef
[src]
impl PartialEq<NodeRef> for NodeRef
[src]
impl StructuralPartialEq for NodeRef
[src]
Auto Trait Implementations
impl !RefUnwindSafe for NodeRef
impl !Send for NodeRef
impl !Sync for NodeRef
impl Unpin for NodeRef
impl !UnwindSafe for NodeRef
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,