bigskysoftware / bigskysoftware/htmx

hx-history not working on partial content

Open
#3,165 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

When using `hx-push-url` with partial content, pressing the back button does not actually work.

From looking at the code, it seems that it's related to the context being on the body.
In the case where we do not actually control the body, the history aspect fails completely.
I have been digging and it seems there is a case where HTMX is loaded dynamically on page load where the DOMContentLoaded is never triggered.

If I instead push the events for the ready function into an array, and then manually call those functions, everything works perfectly.
https://github.com/bigskysoftware/htmx/blob/10e8656af500d8dc3bba54459b8f29d53f326471/src/htmx.js#L4994-L5014

So, we need to find a way to reliably trigger that event... I'll keep looking and update this accordingly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.