pub fn bind<T>(self, var: T) -> Self
    where
        T: StateTrait + 'static,
        T::Value: FromStr + Default,
    {
        self.on_event("input", var, |x, elem| {
            x.put(
                elem.node
                    .node
                    .unchecked_ref::<web_sys::HtmlDataElement>()
                    .value()
                    .parse()
                    .unwrap_or_default(),
            );
        })
    }
/// One way bind to the input element.
/// Any change in the state variable won't be reflected back to the input element.
///
/// # Examples
///
/// ```
/// # use valerie::prelude::*;
/// # use valerie::prelude::components::*;
/// # use wasm_bindgen_test::*;
/// # fn ui() -> Node {
/// let state = StateMutex::new(String::new());
/// div!(
///     state.clone(),
///     br!(),
///     input!("text").bind(state.clone()),
///     input!("text").bind(state)
/// )
/// # .into()
/// # }
/// # wasm_bindgen_test_configure!(run_in_browser);
/// # #[wasm_bindgen_test]
/// # fn run() {
/// #     App::render_single(ui());
/// # }
/// ```
One way bind to the input element.
Any change in the state variable won't be reflected back to the input element.
One way bind to the input element . Any change in the state variable won ' t be reflected back to the input element .
pub fn bind<T>(self, var: T) -> Self
    where
        T: StateTrait + 'static,
        T::Value: FromStr + Default,
    {
        self.on_event("input", var, |x, elem| {
            x.put(
                elem.node
                    .node
                    .unchecked_ref::<web_sys::HtmlDataElement>()
                    .value()
                    .parse()
                    .unwrap_or_default(),
            );
        })
    }
pub fn bind < T > ( self , var : T ) -> Self where T : StateTrait + ' static , T :: Value : FromStr + Default , { self . on_event ( " " , var , | x , elem | { x . put ( elem . node . node . unchecked_ref :: < web_sys :: HtmlDataElement > ( ) . value ( ) . parse ( ) . unwrap_or_default ( ) , ) ; } ) }
One way bind to the input element.
One way bind to the input element .
self
var
T
examples
None
use valerie::prelude::*;
None
use valerie::prelude::components::*;
None
use wasm_bindgen_test::*;
None
fn ui() -> node {
let state = StateMutex::new(String::new());
div!(
state.clone(),
br!(),
input!("text").bind(state.clone()),
input!("text").bind(state)
)
let state = StateMutex :: new ( String :: new () ) ; div! ( state . clone () br! () input! ( " text " ) . bind ( state . clone () ) input! ( " text " ) . bind ( state ) )
.into()
None
}
None
wasm_bindgen_test_configure!(run_in_browser);
None
#[wasm_bindgen_test]
None
fn run() {
None
app::render_single(ui());
None
}
None