gorgeous-ghost-95789
06/24/2021, 4:51 PMfuture-table-82610
06/24/2021, 4:57 PMfuture-table-82610
06/24/2021, 5:01 PMcontext object referred to here: https://htmx.org/api/#ajax any idea how that has to be formed?gorgeous-ghost-95789
06/24/2021, 5:03 PMjavascript
{
source: "the source element of the request",
event: "an event that 'triggered' the request",
handler: "a callback that will handle the response HTML",
target: "the target to swap the response into",
values: "values to submit with the request headers"
}gorgeous-ghost-95789
06/24/2021, 5:03 PMfuture-table-82610
06/24/2021, 5:03 PMgorgeous-ghost-95789
06/24/2021, 5:04 PMhtmx.ajax function. So just define it using {} and you'll be good.future-table-82610
06/24/2021, 5:04 PMtarget in the object.future-table-82610
06/24/2021, 5:06 PMgorgeous-ghost-95789
06/24/2021, 5:30 PMfuture-table-82610
06/24/2021, 5:34 PMhx-include and passing along a few variables. One thing I've noticed, is that I'm setting source in the htmx.ajax call, and the source isn't being turned into the HX-Trigger or HX-Trigger-Name as I'd expect. Am I using that wrong?future-table-82610
06/24/2021, 5:34 PMtarget gets passed along perfectly)gorgeous-ghost-95789
06/24/2021, 5:36 PMhx-trigger is either an attribute on a page element, or a header in your server response. The one I was talking about is the response header. I'm not sure if that is handled in htmx.ajax() or if it's somewhere deeper in the library.gorgeous-ghost-95789
06/24/2021, 5:37 PMfuture-table-82610
06/24/2021, 5:38 PMhtmx.ajax('GET', 'url', {target: "#target-container", source: "source-identifier"}) and submitting it. htmx turns the target into a HX-Target header, but the source just seems to disappear whereas I was expecting (hoping) it would get turned into the HX-Trigger or HX-Trigger-Name header (so I could pass it along to the template being rendered).future-table-82610
06/24/2021, 5:39 PMtarget works I figured there's something I'm missing with source or maybe it's the wrong keyword.gorgeous-ghost-95789
06/24/2021, 5:39 PMhx-trigger is handled in handleAjaxResponse (line 2028 in whatever branch I've got open)gorgeous-ghost-95789
06/24/2021, 5:40 PMhtmx.ajax which means the hx-trigger response header will work if you're using an hx-get="" attribute (or similar) but not if you're calling htmx.ajax directly.gorgeous-ghost-95789
06/24/2021, 5:41 PMfuture-table-82610
06/24/2021, 5:41 PMHX-Target works, but that HX-Trigger doesn't.future-table-82610
06/24/2021, 5:41 PMsource in the context object is a bit pointlessfuture-table-82610
06/24/2021, 5:42 PMgorgeous-ghost-95789
06/24/2021, 5:42 PMgorgeous-ghost-95789
06/24/2021, 5:42 PMbreezy-horse-65573
06/24/2021, 6:00 PMbreezy-horse-65573
06/24/2021, 6:00 PMbreezy-horse-65573
06/24/2021, 6:01 PMgorgeous-ghost-95789
06/24/2021, 6:02 PMgorgeous-ghost-95789
06/24/2021, 6:03 PMhtmx.swap function that handles the cases that you and @future-table-82610 have raised. But so far, that’s still on the back burner.breezy-horse-65573
06/24/2021, 6:05 PM