Closed paxperscientiam closed 2 years ago
Right now we don't do a great job of detecting changes to htmx. In fact, we prevent any updates after the node is first initialized:
The "right thing" here is to allow you to reinitialize the paging node, so maybe something like htmx.reinit(node)
that internally calls https://github.com/bigskysoftware/htmx/blob/3352d5c3e95dad01470e8fc725c61dee1d476593/src/htmx.js#L560 and then htmx.process()
Or maybe we just expose the above internal method as htmx.clear()
?
Yes yes yes. Pleeeease! Begs the question why we cant have this in the first place? I guess to prevent people creating slow code. I accept the responsibilty. Please make it happen. Until then How can I access this hidden cleanUpElement
function? Or is there another hack you would care to share?
As of 1.8.1, htmx.process()
now will inspect a node and, if any attributes have changed, it will re-process them.
See https://github.com/bigskysoftware/htmx/commit/1dbb22b682c625c5054de7127da975f30dfbe6ea
So you can simply modify a node and call htmx.process()
on it. This should fix issues with morphing, etc.
So, I've started some experimenting with making a pagination extension. What I've got so far is really messy, but that's beside the point. Current sticking point is that
htmx.process(element)
seems not work.My goal is to update the
hx-get
attribute each time there's a page turn event. I figured that once I update the attribute value and then runhtmx.process
on the relevant element, all would be good. Unfortunately, the hx-get never gets updated internally.Here's my code so far. What might I be doing wrong?
As an aside, is there a deeper explanation of how the extension API should be used? (https://htmx.org/extensions/#reference). Like with
onEvent()
, there's a slew of events, but it's unclear to me what augmentations should be done when. To me, initial DOM changes (creating previous and next buttons and attaching them) should be done whenhtmx:beforeProcessNode
is fired.Anyway, thanks!