bigskysoftware / bigskysoftware/htmx

Cannot trigger an action on window.load event

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

Description

Hi,

it seems that if I try to trigger an action on window.load event:
`

...
`

the action is triggered immediately. If I understand correctly, it's due to this code:
```
else if (triggerSpec.trigger === "load") {
if (!maybeFilterEvent(triggerSpec, makeEvent("load", {elt:elt}))) {
loadImmediately(elt, handler, nodeData, triggerSpec.delay);
}
}
```
which assumes "load" is always htmx:load, which I guess is always triggered immediately (unless filtered away)?

Would an appropriate fix be something like
```
else if (triggerSpec.trigger === "load" && elt !== window) { ... }
```
or is something more sophisticated needed?

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.