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"