small func

This commit is contained in:
2023-09-13 23:36:56 +02:00
parent e6f143f3c7
commit 33373006e6
2 changed files with 7 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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"