1
0
Эх сурвалжийг харах

added select element example

bluekey 2 жил өмнө
parent
commit
ca0e1fb9ab
1 өөрчлөгдсөн 32 нэмэгдсэн , 0 устгасан
  1. 32 0
      examples/inputs.rs

+ 32 - 0
examples/inputs.rs

@@ -37,6 +37,7 @@ const FIELDS: &[(&str, &str)] = &[
 fn app(cx: Scope) -> Element {
 fn app(cx: Scope) -> Element {
     cx.render(rsx! {
     cx.render(rsx! {
         div { margin_left: "30px",
         div { margin_left: "30px",
+            select_example(cx),
             div {
             div {
                 // handling inputs on divs will catch all input events below
                 // 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)
                 // 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"
+        }
+    }})
+}