htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Change url of request after element has been loaded

Open xegrox opened this issue 3 years ago • 1 comments

Something like

<button id="foo" hx-get="/whatever"> ... </button>
<script>
   foo.setAttribute("hx-get", "/somethingelse");
</script>

Currently, the request url remains /whatever even though the hx-get attribute has been updated

xegrox avatar Jan 20 '22 04:01 xegrox

I'm having the same issue; using htmx.process(node) doesn't seem to do anything and won't update its internal cache when the hx-get is triggered.

oscarsiles avatar Feb 10 '22 10:02 oscarsiles

You can now call htmx.process() on the element to get it to reprocess updated attributes:

<button id="foo" hx-get="/whatever"> ... </button>
<script>
   foo.setAttribute("hx-get", "/somethingelse");
   htmx.process(foo);
</script>

1cg avatar Jan 09 '23 00:01 1cg