https://htmx.org logo
Hi, all! I have a deployed Django site running htm...
# 🔥-django-htmx
w
Hi, all! I have a deployed Django site running htmx and have an issue where the back button after reloading the same page will result in an empty page. Details in thread.
HTMX settings:
Copy code
htmx.config.historyCacheSize = 1;
    htmx.config.refreshOnHistoryMiss = true
    htmx.config.useTemplateFragments = true
m
can you see the request being issued, or is it coming from the cache?
w
Steps to demonstrate: 1. load https://filamentcolors.xyz/library/ 2. In the navbar, click "Color Match" 3. Click Color Match again 4. hit back button
In the network panel or on the server?
Side note: I'm not entirely sure what I'm doing with the settings; my goal is "if it's not in the history, just issue a page refresh" but that doesn't seem to be happening so maybe I'm misunderstanding how to use the settings.
It appears to be requesting assets on the browser, but I will not be able to test on the dev server for a few hours due to work, sorry 😦
m
Ok let me take a look in a few hours
w
Take your time; I appreciate any help!
m
when I click Color Match, I see an ajax request. When I click back, I see another one:
and it does appear to restore the previous page
actually, it looks like it's doing a full page refresh
is there some JS in there?
also, as an aside, I see a lot of repeating
hx-declarations
. Seems like you could hoist some of them up onto the parent elements, maybe the body?
m
Can this have something to do with the HTML document having no
<html></html>
tags?
w
it does restore the previous page, but if you click Color Match twice in a row and then click back, then the restore will fail.
Worth a shot. Didn't even realize they were missing. Will fix.
m
ah yes, thank you history api
I do see this in the console:
w
yes, this is what I'm seeing. Ugh about the init error for the color picker, that's fixable; I don't think that would affect the rest of the page, though
m
can you throw in an unminified version of htmx so I can debug?
w
I will fix both the tags and the loading issue for the color picker asap
m
it's gotta be something simple
w
Yes, will ping when it's done 👍
m
history cache looks sensible enough
daily reminder
w
Sorry for the delay. This has been done!
Also resolved this issue.
@mysterious-toddler-20573 is there anything else I should change / enable to assist?
m
Nope, just patience
🙂
w
That I can do 😅 I appreciate the help.
m
OK, a bit of progress
it looks like it is the settle step that nukes the DOM
is there any scripting that is hooking into the settle step and mutating the DOM? Something around the buy me a coffee link maybe?
w
Not to my knowledge; it's a third-party black box. I can disable it though and see if that helps
though with how small the kofi script is, there's nothing stopping me from just re-implementing it I suppose
either way, I'll disable it and push that update now
@mysterious-toddler-20573 that's 100% the issue -- I can't replicate the crash on local after swapping out the script for a simple button
I am very confused and also a bit mortified that it's that easy
Thank you very much for looking into it, I really appreciate it
m
no problem!