fresh-midnight-60146
03/25/2023, 12:47 AMfresh-midnight-60146
03/25/2023, 12:48 AMgorgeous-airport-54386
03/25/2023, 12:55 AMhx-include
to fix this.gray-morning-3453
03/25/2023, 1:07 AMfresh-midnight-60146
03/25/2023, 1:19 AMgorgeous-airport-54386
03/25/2023, 1:19 AMgorgeous-airport-54386
03/25/2023, 1:25 AMjs
function htmlEscape(string) {
return string
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll("\"", """)
.replaceAll("'", "'")
}
function html(stringParts, ...interpolatedParts) {
return String.raw(stringParts, ...interpolatedParts.map(htmlEscape))
}
// Usage
const userInput = "Hypermedia <script>alert('hacked!')</script> Systems"
console.log(html`<h1>${userInput}</h1>`)
// Output: <h1>Hypermedia <script>alert('hacked!')</script> Systems</h1>
shy-knife-59740
03/25/2023, 1:27 AMfresh-midnight-60146
03/25/2023, 1:28 AMgray-morning-3453
03/25/2023, 1:35 AMgray-morning-3453
03/25/2023, 3:20 AMhtmx:afterRequest
and this solved it. The event got time to reach the modal and then bubble upto the body. And now message toasts are being shown.
At least this is what I think was happening.
Wow, a full day went at this. Well! what can you do?salmon-oil-67352
03/25/2023, 8:53 PMlimited-teacher-83117
03/25/2023, 9:12 PMlimited-teacher-83117
03/25/2023, 9:14 PMhtmx
to load certain elements when the page is created, with hx-trigger=load
. That may or may not be suitablesalmon-oil-67352
03/25/2023, 9:53 PMresponse["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
response["Pragma"] = "no-cache" # HTTP 1.0.
response["Expires"] = "0" # Proxies.
From the stack overflow link you sent. Now when I do CTRL+Back button, the page opens in a new window, refreshes and is rendered correctly (which it did not do previously).
But I use HX-Boost all my links, and when I simply click the back button the page does not refresh with this technique :/salmon-oil-67352
03/25/2023, 10:14 PMsalmon-oil-67352
03/25/2023, 11:59 PM$(document).ready(function() {
window.onpopstate = function (event) {
location.reload();
};
});
It seems to work as it should, is this a dirty workaround? Or a proper simple solution?limited-teacher-83117
03/26/2023, 4:07 PMshy-knife-59740
03/26/2023, 10:47 PMhtml
<div>
<select name="sort" hx-get="/posts" hx-target="#postlist">
<option value="id">id</option>
<option value="date">date</option>
</select>
<select name="order" hx-get="/posts" hx-target="#postlist">
<option value="asc">ascending</option>
<option value="desc">descending</option>
</select>
</div>
<div hx-get="/posts" hx-swap="outerHTML" hx-trigger="load"></div>
which works fine but they dont work well togethershy-knife-59740
03/26/2023, 10:47 PMshy-knife-59740
03/26/2023, 10:49 PMmysterious-toddler-20573
03/26/2023, 11:17 PM<form/>
tag and both values will be submitted together for eachshy-knife-59740
03/26/2023, 11:18 PMshy-knife-59740
03/26/2023, 11:21 PMhx-get="/posts" hx-target="#postlist"
to it. i still need a submit buttonshy-knife-59740
03/26/2023, 11:22 PMshy-knife-59740
03/26/2023, 11:38 PMjs
<script>
document.getElementById("postform").addEventListener("change", ({ target }) => target.form.submit());
</script>
but this reload the whole pagemysterious-toddler-20573
03/26/2023, 11:44 PMmysterious-toddler-20573
03/26/2023, 11:44 PMmysterious-toddler-20573
03/26/2023, 11:44 PM