stocky-dentist-80693
05/18/2023, 8:33 AMname attribute.
If the filter inputs can't be inside the form for whatever reason, you can also add a form attribute to each filter input to link it to the tag by ID, which should still work.
Alternatively, if you want more control over other htmx directives like target/swaps/etc, you can skip hx-boost, and use hx-get on the form along with hx-push-url="true".astonishing-cpu-59399
05/18/2023, 9:46 AMhx-trigger="load" is not working on boosted links. Anyone have idea?
<!-- this is working, triggering GET /subpage after load-->
<div>
<a hx-get="/subpage" hx-trigger="load">Sub Page</a>
</div>
<!-- this is not working, not triggering GET /subpage after load -->
<div hx-boost="true">
<a href="/subpage" hx-trigger="load">Sub Page</a>
</div>mammoth-family-48524
05/18/2023, 10:54 AMshy-knife-59740
05/18/2023, 1:06 PMshy-knife-59740
05/18/2023, 1:06 PMshy-knife-59740
05/18/2023, 1:07 PMshy-knife-59740
05/18/2023, 1:07 PMshy-knife-59740
05/18/2023, 1:07 PMicy-vase-29164
05/18/2023, 1:15 PMgifted-airline-5816
05/18/2023, 3:38 PMgreat-cartoon-12331
05/18/2023, 4:24 PMgreat-cartoon-12331
05/18/2023, 4:32 PMHX-Request header and the ?hx=1 query param. otherwise a user might manually enter a URL with ?hx=1 param and hit Enter, but we don't want to render a partial for that because it's not an htmx request.gifted-airline-5816
05/18/2023, 4:37 PMgreat-cartoon-12331
05/18/2023, 4:38 PMfreezing-waitress-26396
05/18/2023, 6:55 PMshy-zebra-22292
05/18/2023, 7:25 PMshy-zebra-22292
05/18/2023, 7:25 PMgreat-cartoon-12331
05/18/2023, 7:46 PMgreat-cartoon-12331
05/18/2023, 7:56 PMgreat-cartoon-12331
05/18/2023, 7:57 PMsquare-analyst-94375
05/18/2023, 7:57 PMhx-include="false" didn't work)mammoth-family-48524
05/18/2023, 9:38 PMmammoth-family-48524
05/18/2023, 9:39 PMsquare-analyst-94375
05/18/2023, 9:39 PMgreat-cartoon-12331
05/18/2023, 9:53 PMocaml
let htmx req =
match Dream.header req "Accept" with
| Some "text/html;hx=1" -> true
| _ -> falsegreat-cartoon-12331
05/18/2023, 11:45 PMjavascript
// On form submit, clear the form.
document.addEventListener('htmx:afterOnLoad', evt => {
const frm = evt.detail.elt;
if (frm instanceof HTMLFormElement) {
frm.reset();
}
});
// If there's an error response, show it in the toast
document.addEventListener('htmx:responseError', evt => {
document.getElementById('toast').outerHTML =
`<p id="toast" class="error">${evt.detail.xhr.responseText}</p>`;
});aloof-crayon-56651
05/19/2023, 4:49 AMhttps://cdn.discordapp.com/attachments/725789747212976259/1108979717496897556/2023-05-19_13.47.53.png▾
https://cdn.discordapp.com/attachments/725789747212976259/1108979717786320916/2023-05-19_13.48.07.png▾
busy-ocean-3407
05/19/2023, 7:55 AMrequest.form object to get the form data.
username = request.form.get('username')
password = request.form.get('password')
print(username,password)
# Now you can use username and password in your logic...
# Always return a response
return "Form data received!"
However There seems to be no possibility to retrieve username/password
if I need the submit button to be outside the form.
I can be done easily with vanilla javascript.
NB: hx-vals="{json: getFormValues()}" did not solve the issue .* I am looking for a confirmation that it is not possible without javascript.*bland-rainbow-1285
05/19/2023, 8:44 AM