some refractoring and dataholder

This commit is contained in:
2024-11-25 14:30:59 +01:00
parent f8fd990c67
commit 0266c26d34
7 changed files with 116 additions and 184 deletions
+10 -2
View File
@@ -3,8 +3,16 @@ use crate::prelude::*;
pub fn examples() -> Element {
rsx! {
styling: Some(styling()),
if (2 == 2) {
rsx_elem! { button { class: "btn", "Hello, World!" } }
button { class: "btn", on_click: Handler::new(|btn: &mut Button, _, document| {
let data = document.get_element_by_id::<DataHolder<'_, String>>("my_data").unwrap();
data.data += "!";
btn.children.set_text(&data.data);
}), "Hello, World!" }
{
let mut data = dataholder::<String>();
data.id = "my_data";
data
}
}
}