pub fn bind_func<T, F>(self, var: T, func: F) -> Self
    where
        T: StateTrait + 'static,
        F: FnOnce(String) -> T::Value,
        F: 'static + Copy,
    {
        self.on_event("input", var, move |x, elem| {
            x.put(func(
                elem.node
                    .node
                    .unchecked_ref::<web_sys::HtmlDataElement>()
                    .value(),
            ));
        })
    }
/// A function to bind to the input element.
/// This function gets called every time the event `input` fires i.e. when the user enters and input.
///
/// # Examples
///
/// ```
/// # use valerie::prelude::*;
/// # use valerie::prelude::components::*;
/// # use wasm_bindgen_test::*;
/// # fn ui() -> Node {
/// let state = StateAtomic::new(0usize);
/// div!(
///     state.clone(),
///     br!(),
///     input!("text").bind_func(state, |x| x.len())
/// )
/// # .into()
/// # }
/// # wasm_bindgen_test_configure!(run_in_browser);
/// # #[wasm_bindgen_test]
/// # fn run() {
/// #     App::render_single(ui());
/// # }
/// ```
A function to bind to the input element.
This function gets called every time the event `input` fires i.e. when the user enters and input.
A function to bind to the input element . This function gets called every time the event ` input ` fires i . e . when the user enters and input .
pub fn bind_func<T, F>(self, var: T, func: F) -> Self
    where
        T: StateTrait + 'static,
        F: FnOnce(String) -> T::Value,
        F: 'static + Copy,
    {
        self.on_event("input", var, move |x, elem| {
            x.put(func(
                elem.node
                    .node
                    .unchecked_ref::<web_sys::HtmlDataElement>()
                    .value(),
            ));
        })
    }
pub fn bind_func < T , F > ( self , var : T , func : F ) -> Self where T : StateTrait + ' static , F : FnOnce ( String ) -> T :: Value , F : ' static + Copy , { self . on_event ( " " , var , move | x , elem | { x . put ( func ( elem . node . node . unchecked_ref :: < web_sys :: HtmlDataElement > ( ) . value ( ) , ) ) ; } ) }
A function to bind to the input element.
A function to bind to the input element .
self
var
T
func
F
examples
None
use valerie::prelude::*;
None
use valerie::prelude::components::*;
None
use wasm_bindgen_test::*;
None
fn ui() -> node {
let state = StateAtomic::new(0usize);
div!(
state.clone(),
br!(),
input!("text").bind_func(state, |x| x.len())
)
let state = StateAtomic :: new ( 0usize ) ; div! ( state . clone () br! () input! ( " text " ) . bind_func ( state |x| x . len () ) )
.into()
None
}
None
wasm_bindgen_test_configure!(run_in_browser);
None
#[wasm_bindgen_test]
None
fn run() {
None
app::render_single(ui());
None
}
None