bigskysoftware / htmx-extensions

167 stars 51 forks source link

Preload: stopping event propagation when priming a cache? #90

Open meln1k opened 2 months ago

meln1k commented 2 months ago

I have a spinner overlay which is triggered via htmx:beforeRequest and htmx:afterRequest events, and when I use the preload extension with hx-get, the "cache priming" request sends those events and this triggers the overlay (which is undesirable since it happens on mouseover).

Shouldn't those events be caught and prevented from propagation (to keep the cache priming side-effects free)?

Telroshan commented 2 months ago

There had been a PR about that on the htmx repo (back when extensions were in the same repo), see https://github.com/bigskysoftware/htmx/pull/1511

Seems it got closed due to inactivity but the suggested change had been approved. If you'd like to look into it and submit a bugfix PR, feel free to do so, PR welcome!

meln1k commented 2 months ago

Cool, I created a PR #91 which should add side-effect free handling for hx-get requests.