Merge pull request #973 from Icekey/select_example
added select element example
This commit is contained in:
1 file changed
+32
@@ -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"
|
||||||
|
}
|
||||||
|
}})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user