Defining Our AdonisJS Filter Form Handler
In this lesson, we'll expand on the filter query we built in the last lesson by reusing the query within a service for our filter form handler.
- Author
- Tom Gobich
- Published
- Mar 26, 23
- Duration
- 6m 57s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.
Adocasts
Burlington, KY
Get the Code
Download or explore the source code for this lesson on GitHub
-
1.0Installing HTMX & Project OverviewLesson 1.03m 8s
-
2.0Creating Our Filter Query with AdonisJSLesson 2.03m 4s
-
3.0Defining Our AdonisJS Filter Form HandlerLesson 3.06m 57s
-
4.0Posting & Swapping Filtered Content with HTMXLesson 4.03m 29s
-
5.0Updating Our URL & Populating Filter Field ValuesLesson 5.03m 32s
Join The Discussion! (2 Comments)
Please sign in or sign up for free to join in on the dicussion.
virimchi-m
Hi, if a request is NOT a HTMX I want the response to be embedded in the @layout. But if it is a HTMX request, I want the response to be from the edge template alone without the enclosing content such as Header, footer. How do you handle this? Are you having a filter to detect hx-request header and conditional logic in the @layout file?
Please sign in or sign up for free to reply
tomgobich
Hi virimchi-m!
Yep, you could absolutely do that! If the
HX-Request
header is there then HTMX sent the request, so you can use that to conditionally determine whether to render your layout or not. If needed you can also use the target, via theHX-Target
header, to determine if the layout needs rerendered.Alternatively, you could put the contents you want to render within a component, very similar to how we did it in this series with our
post_list
then render that component directly!Then, we can use this component within the page:
We can conditionally render it directly from our controller.
Please sign in or sign up for free to reply