Skip to content

Commit

Permalink
Use relative paths for hx requests
Browse files Browse the repository at this point in the history
  • Loading branch information
DonRobo committed Jul 21, 2024
1 parent d7e1e4e commit c07bd1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/src/main/kotlin/at/robert/hf/htmx/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.html.*

val hxObjectMapper = jacksonObjectMapper()
fun Tag.hxPost(hxCtx: HtmxContext, vararg params: Pair<String, Any>) {
attributes["hx-post"] = hxCtx.route
attributes["hx-post"] = hxCtx.route.removePrefix("/")
attributes["hx-target"] = "#${hxCtx.component}"
attributes["hx-swap"] = "innerHTML"
attributes["hx-vals"] = params.toMap().let { hxObjectMapper.writeValueAsString(it) }
Expand All @@ -17,7 +17,7 @@ fun FlowContent.hxActionForm(
block: FORM.() -> Unit
) {
form {
attributes["hx-post"] = hxCtx.route
attributes["hx-post"] = hxCtx.route.removePrefix("/")
attributes["hx-target"] = "#${hxCtx.component}"
attributes["hx-swap"] = "innerHTML"

Expand Down

0 comments on commit c07bd1a

Please sign in to comment.