gorgeous-airport-54386
07/14/2021, 6:19 PMelegant-london-97728
07/14/2021, 6:37 PMelegant-london-97728
07/14/2021, 6:54 PMuser
07/14/2021, 6:56 PMelegant-london-97728
07/14/2021, 7:02 PMelegant-london-97728
07/14/2021, 7:04 PMuser
07/14/2021, 7:10 PMelegant-london-97728
07/14/2021, 7:15 PMuser
07/14/2021, 7:16 PMmysterious-toddler-20573
07/14/2021, 7:34 PMmysterious-toddler-20573
07/14/2021, 7:36 PMsalmon-xylophone-28580
07/15/2021, 7:10 AMelegant-london-97728
07/15/2021, 7:33 AM_page
as a suffix for full-page responses (treating this as a default: no suffix === full-page response, so existing codebases fit this pattern)elegant-london-97728
07/15/2021, 7:35 AM_hx
cover both GET and POST, with _hxget
and _hxpost
forcing one or the other.elegant-london-97728
07/15/2021, 7:40 AM/hx/
subdirectories, kind of like /partials/
but for htmx.elegant-london-97728
07/15/2021, 7:41 AMsalmon-xylophone-28580
07/15/2021, 7:42 AMsalmon-xylophone-28580
07/15/2021, 7:43 AMelegant-london-97728
07/15/2021, 8:23 AMsalmon-xylophone-28580
07/15/2021, 8:51 AMmysterious-toddler-20573
07/15/2021, 1:38 PM/views/contacts/index.html.erb
- main template for the contacts controller root URL
and if that has something like the active search pattern in it:
html
<h3>
Search Contacts
<span class="htmx-indicator">
<img src="/img/bars.svg"/> Searching...
</span>
</h3>
<input class="form-control" type="text"
name="search" placeholder="Begin Typing To Search Users..."
hx-post="/search"
hx-trigger="keyup changed delay:500ms"
hx-target="#search-results"
hx-indicator=".htmx-indicator">
<table class="table">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
</thead>
<tbody id="search-results">
</tbody>
</table>
I'll use the ID of the element I am targeting for a template name:
/views/contacts/_search_result.html.erb
mysterious-toddler-20573
07/15/2021, 1:38 PMresults_table
or something, so I have a better file namemysterious-toddler-20573
07/15/2021, 1:41 PM/search
url would look something like this:
rb
if request.headers['HX-Request']
render "_search_results.html.erb" # render the partial
else
render "index.html.erb" # render the whole UI w/ search results
mysterious-toddler-20573
07/15/2021, 1:43 PMindex.html.erb
template will include the search_results.html.erb
template so it can be used as the template for both the root request as well as /search
requestsmysterious-toddler-20573
07/15/2021, 1:43 PMclean-vegetable-65167
07/15/2021, 1:54 PMmysterious-toddler-20573
07/15/2021, 1:56 PMmysterious-toddler-20573
07/15/2021, 1:56 PMmysterious-toddler-20573
07/15/2021, 1:57 PMsalmon-xylophone-28580
07/15/2021, 2:04 PM