From 33373006e6ec787753fa1d912671199a60b9d2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Wed, 13 Sep 2023 23:36:56 +0200 Subject: [PATCH] small func --- src/view/mod.rs | 5 +++++ src/view/root.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/view/mod.rs b/src/view/mod.rs index 7968d1c..e54b591 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -99,6 +99,11 @@ impl ComponentId { // URL_SAFE because we cannot have slashes in the output base64::engine::general_purpose::URL_SAFE.encode(id) } + + #[tracing::instrument] + fn selector(&self) -> String { + format!("#{}", self.html_id()) + } } impl fmt::Display for ComponentId { diff --git a/src/view/root.rs b/src/view/root.rs index 549a501..35c2dfb 100644 --- a/src/view/root.rs +++ b/src/view/root.rs @@ -62,7 +62,7 @@ impl<'a> Component for HeaderLink<'a> { a href=(self.args.item.path()) hx-get=(self.args.item.path()) - hx-target={ "#" (self.htmx.target().html_id()) } + hx-target=(self.htmx.target().selector()) hx-swap="outerHtml" hx-push-url="true" #{"header-link-" (self.args.item.id())} @@ -129,7 +129,7 @@ impl<'a> Component for Body<'a> { #home href=(self.htmx.fallback_action) hx-get=(self.htmx.action) - hx-target={ "#" (self.htmx.target()) } + hx-target=(self.htmx.target().selector()) hx-swap="outerHTML" ."flex" ."flex-row"