-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detection of partial htmx request in the presence of hx-history #410
Comments
I’ll consider it if there is more support for the idea. I am not sure how many people use the history feature. |
This happens due to the fact that the htmx part is HTTP cached just by the URL, so it doesn't really know the difference between a htmx request and a full page request You need to set I think a lot of people will use the history feature, intentionally or not. For example, if you filter on data, you probably use It's easy to add the headers yourself, but I do would like to see it added to the library, since it's a subtle "bug" that you might not notice unless you properly test moving back and forth between your pages while having features that rely on history. |
You are correct on the importance of I am just saying that if you ever use |
Could you provide an example that demonstrates this issue? I'm missing some detail. I tried having hx-history set globally, and then used a history feature like hx-push-url, and then the issue of going back not doing a full page reload appears, then the |
The problem seems to be introduced here: bigskysoftware/htmx#2013 . Checking for A way to simulate (even without using
Now the fresh partial content would load to the top window. Backend should had generated full page. |
I tried to reproduce and "simulate" according to your instructions, and it works as expected with backend generating a full page on back button (with Vary: Accept) What version of HTMX are you on? What browser? Maybe something else is different for me |
I have created a demo: https://github.com/brablc/htmx-sandbox . It uses latest htmx 1.9.10 and I run Firefox, but this should not matter. |
In reference to conversation on #410.
In reference to this, I have added some docs for setting I’m still not exactly sure whether to change anything about |
Python Version
3.11.6
Django Version
4.2.6
Package Version
1.17
Description
The documentation says the detection of a partial htmx request should be:
if request.htmx:
. However in the presence ofhx-history
anywhere on the page, when navigating back to this page a full page needs to be returned. To properly handle this situation it is actually necessary to use:if request.htmx and not request.htmx.history_restore_request:
.I would suggest adding something like
request.htmx_partial_request
.The text was updated successfully, but these errors were encountered: