From ca0e1fb9ab61466d61dbff1671612852e6a06497 Mon Sep 17 00:00:00 2001 From: bluekey Date: Sun, 23 Apr 2023 17:15:06 +0200 Subject: [PATCH] added select element example --- examples/inputs.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/inputs.rs b/examples/inputs.rs index cf848d99e..311afc1f0 100644 --- a/examples/inputs.rs +++ b/examples/inputs.rs @@ -37,6 +37,7 @@ const FIELDS: &[(&str, &str)] = &[ fn app(cx: Scope) -> Element { cx.render(rsx! { div { margin_left: "30px", + select_example(cx), div { // handling inputs on divs will catch all input events below // so the value of our input event will be either huey, dewey, louie, or true/false (because of the checkboxe) @@ -134,3 +135,34 @@ fn app(cx: Scope) -> Element { } }) } + +fn select_example(cx: Scope) -> Element { + cx.render(rsx! { + div { + select { + id: "selection", + name: "selection", + multiple: true, + oninput: move |evt| { + println!("{evt:?}"); + }, + option { + value : "Option 1", + label : "Option 1", + } + option { + value : "Option 2", + label : "Option 2", + selected : true, + }, + option { + value : "Option 3", + label : "Option 3", + } + } + label { + r#for: "selection", + "select element" + } + }}) +}