Clone in a terminal:
Commit 1416946
Johan Mattsson - 2026-06-11T18:53:48+00:00
14169464c43ec86a0ddb1094d7106b202cae5ea4johan.mattsson.m@gmail.com

More examples

Changed files (1)

Diff

diff --git a/README.md b/README.mdindex 1c3e72c..0884254 100644--- a/README.md+++ b/README.md@@ -1,4 +1,4 @@-# Web Framework: kaja-web - for Web Applications written in Rust+# Web Framework: kaja-web – for Web Applications written in Rust  The key concept and idea behind the design is that HTML content is managed as strings and the code is compiled to WebAssembly. There is no Domain Specific@@ -8,6 +8,10 @@ functions in onclick handlers (and also other event handlers). There are also a number of helper functions available to make it easier to interact with the browser. +No state changes triggers re-render automatically, run the update function+manually when you want to render a component and use `inner_html("#the-id", content)`+to update the  DOM.+ ## Example: ```rust use kaja_web::prelude::*;@@ -36,8 +40,6 @@ fn update_counter_display(app_data: &AppData) { }  fn main() {-    // Init callbacks to make sure functions annotated with `#[callback]`-    // are available as global functions on the DOM     init_callbacks();       let mut app_data = APP_DATA.write().unwrap();@@ -52,6 +54,36 @@ This example requres an html file with this content:  See examples/clickcounter for full example. +# Passing Objects from JS Callbacks to Rust WASM++This requires `serde::Deserialize;`.++```rust+use kaja_web::prelude::*;+use serde::Deserialize;+use web_sys::KeyboardEvent;++#[derive(Deserialize)]+pub struct TestData {+    test_parameter: String,+}++fn update_component() {+    let content = html! {{+        <button onclick="foo({ test_parameter: 'test' })">Click me</button>+    }};++    inner_html(".main-content", content);+}++#[callback(foo)]+fn foo(data: TestData) {+    let mut app_data = APP_DATA.write().unwrap();+    app_data.current_count += 1;+    update_counter_display(&app_data);+}+```+ ## The Macros The HTML code is generated using the `kaja-html-macro` crate. The callback functions are definedusing the `kaja-callback-macro` crate. Helper functions

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112