htmx-extensions icon indicating copy to clipboard operation
htmx-extensions copied to clipboard

Do not emit htmx events when preloading requests

Open meln1k opened this issue 1 year ago • 3 comments

As discussed on #90, here is a change to make prefetch hx-get request side-effect free.

meln1k avatar Sep 13 '24 16:09 meln1k

Deploy Preview for htmx-extensions canceled.

Name Link
Latest commit 87758436460f28c14976da8983f195abf1ad2b17
Latest deploy log https://app.netlify.com/sites/htmx-extensions/deploys/66ec6ce4bcb1d100088ffe76

netlify[bot] avatar Sep 13 '24 16:09 netlify[bot]

Hey, could you remove the formatting changes to make the overall diff more readable and easier to review? Thanks!

Telroshan avatar Sep 14 '24 08:09 Telroshan

@Telroshan done!

meln1k avatar Sep 17 '24 17:09 meln1k

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!

marisst avatar Nov 11 '24 12:11 marisst

closing in favour of #106

meln1k avatar Nov 26 '24 10:11 meln1k