freezing-sugar-15438
01/20/2023, 8:57 PMmysterious-toddler-20573
01/20/2023, 9:06 PMmysterious-toddler-20573
01/20/2023, 9:06 PMfreezing-sugar-15438
01/20/2023, 9:07 PMblue-toothbrush-6988
01/20/2023, 9:30 PM<input id="search" type="search"
name="search" class="form-control float-right" placeholder="Search"
hx-post="{% url 'stock:search' %}"
hx-trigger="keyup changed delay:500ms, search"
hx-target="#search-results"
hx-include="[name='search']"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
>
blue-toothbrush-6988
01/20/2023, 9:31 PM<div class="row">
<div class="col-sm">
{% for hwarehouse in warehouse %}
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="customCheckbox{{ hwarehouse.id }}" value="option1" checked>
<label for="customCheckbox{{ hwarehouse.id }}" class="custom-control-label">{{ hwarehouse.name }}</label>
</div>
{% if forloop.counter|divisibleby:5 %}
</div>
<div class="col-sm">
{% endif %}
{% endfor %}
</div>
</div>
blue-toothbrush-6988
01/20/2023, 9:31 PMblue-toothbrush-6988
01/20/2023, 9:31 PMlate-king-98305
01/20/2023, 9:48 PMhx-post
will include all input
elements. They will be submitted with their name
attribute. If they are checked, the server-side value will be the value
attribute from the checkbox, or "on" if there is a checkbox without a value. If they are not checked, they will not be present at all. I'm not sure what you're using on the server side, but the name can be structured so that you can access the checkboxes as an array. For PHP, you'd end the name with "[]"; for ASP.NET, you'll have to provide an index ("[0]", "[1]", etc.) and filter out the nulls.
If you're not inside a form
(and don't want to be... LOL), I'm not sure hx-include
takes a query selector. If it does, though, the syntax to get all input
elements whose id
attributes start with "customCheckbox" would be input[id^=customCheckbox]
. I've never done that, so I don't know what it would look like server-side.late-king-98305
01/20/2023, 9:49 PMblue-toothbrush-6988
01/20/2023, 9:54 PMlate-king-98305
01/20/2023, 10:02 PMrequest.POST.getList()
to access them as an array. https://stackoverflow.com/questions/44628251/how-to-get-array-of-values-from-checkbox-form-djangolate-king-98305
01/20/2023, 10:05 PMadventurous-ocean-93733
01/20/2023, 10:06 PM<form>
then as @late-king-98305 said, this code would work:
<input id="search" type="search"
name="search" class="form-control float-right" placeholder="Search"
hx-post="{% url 'stock:search' %}"
hx-trigger="keyup changed delay:500ms, search"
hx-target="#search-results"
hx-include="[name='search']"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
>
<div class="row">
<div class="col-sm">
{% for hwarehouse in warehouse %}
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" name="yourCheckBox" id="customCheckbox{{ hwarehouse.id }}" value="option1" checked>
<label for="customCheckbox{{ hwarehouse.id }}" class="custom-control-label">{{ hwarehouse.name }}</label>
</div>
{% if forloop.counter|divisibleby:5 %}
</div>
<div class="col-sm">
{% endif %}
{% endfor %}
</div>
</div>
And the page you're submitting to can access all the checked options within the param yourCheckBox
brave-dog-98297
01/20/2023, 10:07 PMblue-toothbrush-6988
01/20/2023, 10:09 PMlemon-carpenter-66863
01/21/2023, 10:26 PMmysterious-toddler-20573
01/21/2023, 11:25 PMflaky-energy-47039
01/21/2023, 11:42 PM<button class="btn btn-sm btn-outline-success"
hx-get="http://localhost:8080/meetings/declare_partic/19/1"
_="on htmx:confirm(issueRequest)
halt the event
call Swal.fire({
title: 'Registravimosi patvirtinimas',
text:'Norite registruotis 2023-01-27 d. renginiui?',
icon:'question',
showCancelButton:true
})
if result.isConfirmed issueRequest()" hx-target="#meeting_19" hx-swap="outerHTML swap:0.5s">
<i class="bi bi-person-plus-fill"></i> Dalyvausiu
</button>
mysterious-toddler-20573
01/21/2023, 11:55 PMflaky-energy-47039
01/21/2023, 11:56 PMflaky-energy-47039
01/22/2023, 8:16 AMripe-action-67367
01/22/2023, 8:22 AMflaky-energy-47039
01/22/2023, 9:00 AMbillions-easter-81130
01/22/2023, 7:18 PM<script src="">
references are now properly loaded, but some weird stuff can still happen due to the loading/execution of external .js
files happening aynchronously? Or should 60a6717
actually fix the issue entirely and external .js files should be loaded and executed in a synchronous fashion?billions-easter-81130
01/22/2023, 7:24 PM.js
files not being loaded and executed before moving on to parse the rest of the document (i.e. the browser effectively acting as if the <script src="">
-tag contained async
or defer
if visiting a boosted link) would explain some problems I've not been able to fix for quite some time.gray-morning-3453
01/23/2023, 6:27 AMmainModalClose()
which is using remove() to remove the modal from the DOM. If I dont do this, the event is handled as desired, but when the modal is removed the event is getting lost. The event handler is connected to the body element and works in other situation.
function submitForm(){
htmx.ajax('POST', '{% url "edit_event" %}', {target:'body', swap: 'beforeend', source: form});
mainModalClose();
}
I thought when the headers are received by the client the event would bubble upto the body but it seems if the modal element which is sending the POST is not present something else happens.adventurous-ocean-93733
01/23/2023, 2:51 PMhx-boost
it processes the title
tag toomysterious-toddler-20573
01/23/2023, 3:42 PM