brash-machine-54411
02/05/2023, 10:15 AMripe-action-67367
02/05/2023, 10:25 AMripe-action-67367
02/05/2023, 10:27 AMbrash-machine-54411
02/05/2023, 10:29 AMswift-arm-37963
02/05/2023, 10:37 AMbland-coat-6833
02/05/2023, 11:07 AMhx-fragment
attribute? It would just add a new header to the request with the fragment name. At the moment I define multiple routes on the server - one for each fragment. Having a header to inspect in a single route could simplify the code. Does that sound useful to anyone?brash-machine-54411
02/05/2023, 11:28 AMripe-action-67367
02/05/2023, 1:46 PMmysterious-toddler-20573
02/05/2023, 4:13 PMmysterious-toddler-20573
02/05/2023, 4:15 PMtemplate
tags and you will get the behavior you probably wantmysterious-toddler-20573
02/05/2023, 4:16 PMbrash-machine-54411
02/05/2023, 5:20 PMbrash-machine-54411
02/05/2023, 5:21 PMfamous-iron-45600
02/05/2023, 5:40 PM<div id="login-form">
<template
hx-ext="restored"
hx-trigger="restored"
hx-get="/auth/login"
hx-swap="outerHTML"
hx-target="#login-form"
></template>
<form
action="/auth/login"
method="post"
hx-swap="outerHTML"
hx-target="this"
>
<div class="error">{this.formError}</div>
<label for="username">Username:</label>
<br />
<input type="text" id="username" name="username" hx-preserve />
<br />
<div class="error">{this.parseErrorMsg('username')}</div>
<label for="password">Password:</label>
<br />
<input type="text" id="password" name="password" hx-preserve />
<div class="error">{this.parseErrorMsg('password')}</div>
<input type="submit" value="Login"></input>
</form>
</div>
The purpose of having a template
tag in it is to prevent the user to log in again if he clicks the browser back btn. It works like this: if the user clicks the browser back, the restored
event is emitted and GET /auth/login
request returns hx-location
header if he already has a session. This works fine, however, I'm not sure if there is a better way to achieve the same goal.
The problem I have with this approach is when the user is authenticated and does a page refresh. In this case, if he goes back to login
by clicking browser back btn, the restored
event is not emitted. Is this a bug?echoing-lion-55988
02/05/2023, 6:37 PMechoing-lion-55988
02/05/2023, 6:39 PMrefined-manchester-67193
02/05/2023, 7:07 PMrefined-manchester-67193
02/05/2023, 7:08 PMripe-action-67367
02/05/2023, 7:15 PMripe-action-67367
02/05/2023, 7:16 PMrefined-manchester-67193
02/05/2023, 7:16 PMripe-action-67367
02/05/2023, 7:17 PMrefined-manchester-67193
02/05/2023, 7:17 PMrefined-manchester-67193
02/05/2023, 7:18 PMripe-action-67367
02/05/2023, 7:21 PMrefined-manchester-67193
02/05/2023, 7:22 PMripe-action-67367
02/05/2023, 7:25 PMrefined-manchester-67193
02/05/2023, 7:29 PMripe-action-67367
02/05/2023, 7:30 PMrefined-manchester-67193
02/05/2023, 7:30 PM