Do not emit htmx events when preloading requests
As discussed on #90, here is a change to make prefetch hx-get request side-effect free.
Deploy Preview for htmx-extensions canceled.
| Name | Link |
|---|---|
| Latest commit | 87758436460f28c14976da8983f195abf1ad2b17 |
| Latest deploy log | https://app.netlify.com/sites/htmx-extensions/deploys/66ec6ce4bcb1d100088ffe76 |
Hey, could you remove the formatting changes to make the overall diff more readable and easier to review? Thanks!
@Telroshan done!
I have fixed this issue in https://github.com/bigskysoftware/htmx-extensions/pull/106, since I was receiving two comments about it there. I have used @meln1k solution as a foundation and implemented @Telroshan idea to reuse the xhr generated by htmx.ajax() and null the HTMX callbacks. Additionally, I am triggering the process in what I believe is a more rigid way to avoid bugs. Instead of attaching prefetchEventHandler to all preloaded node in the loading function, I make the extension listen to all htmx:beforeRequest events and check for those which include "HX-Preload": "true" header. I hope you like it!
closing in favour of #106