melodic-translator-29773
12/21/2021, 12:43 AMmelodic-translator-29773
12/21/2021, 12:45 AMbroad-baker-92644
12/22/2021, 4:49 AMblue-gold-89534
12/22/2021, 1:58 PMblue-gold-89534
12/22/2021, 1:59 PMblue-gold-89534
12/22/2021, 2:48 PMgorgeous-airport-54386
12/22/2021, 2:48 PMHX-Request
header exists on the response.gorgeous-airport-54386
12/22/2021, 2:49 PMblue-gold-89534
12/22/2021, 3:08 PMif "hx-request" in request.headers.keys()
if headers.request["hx-request"] == True: ...
- is there a shorter approach?gorgeous-airport-54386
12/22/2021, 3:10 PMif "hx-request" in request.headers
should be enoughblue-gold-89534
12/22/2021, 3:16 PMmysterious-toddler-20573
12/22/2021, 3:16 PMmysterious-toddler-20573
12/22/2021, 3:16 PMblue-gold-89534
12/22/2021, 3:17 PMblue-gold-89534
12/22/2021, 3:17 PMmysterious-toddler-20573
12/22/2021, 3:17 PMmysterious-toddler-20573
12/22/2021, 3:17 PMblue-gold-89534
12/22/2021, 3:23 PMblue-gold-89534
12/22/2021, 3:23 PM<main id="main">{% include "table.hmtl" %} </main>
and in table.html I have a:
<nav hx-boost="true" hx-target="#main" hx-swap="outerHTML"> ... </nav>
blue-gold-89534
12/22/2021, 3:24 PMswap=innerHTML
?abundant-breakfast-94967
12/22/2021, 11:35 PMbland-coat-6833
12/23/2021, 12:47 PMrequest.htmx
in your template. I use that to decide whether to extend from a base template. Eg in your example, if request.htmx
is false then you would extend from index.html. If itβs true then donβt extend and just return table.htmlbland-coat-6833
12/23/2021, 12:48 PMblue-gold-89534
12/23/2021, 12:56 PMabundant-breakfast-94967
12/23/2021, 8:19 PMabundant-breakfast-94967
12/23/2021, 8:26 PMThe
<select
class="h-full text-lg bg-gray-200 rounded"
name="insurance"
hx-get="/app/plan_options"
hx-target="#plan-select-holder"
hx-trigger="change"
hx-swap="innerHTML"
>
<option class="tex-gray-500" select value="">Insurance Provider</option>
<option value="aetna">Aetna</option>
<option value="united">United</option>
<option value="bcbs">Blue Cross Blue Shield</option>
</select>
<div id="plan-select-holder"></div>
HTML that is returned by plan options
<select id="plan-select">
{% for opt in options %}
<option value="{{opt}}">{{opt}}</option>
{% endfor %}
</select>
<script>
new TomSelect('#plan-select',{
plugins: ['dropdown_input'],
});
</script>
blue-gold-89534
12/23/2021, 10:54 PMabundant-breakfast-94967
12/23/2021, 11:11 PM