Intercept htmx on submit requests, this allows auto submit from nfc fields

This commit is contained in:
Antoine Bartuccio 2024-11-14 16:53:39 +01:00
parent 7110891aeb
commit a8ceb8a200
2 changed files with 14 additions and 13 deletions

View File

@ -1,15 +1,14 @@
<div id="student_card_form">
<h3>{% trans %}Add a student card{% endtrans %}</h3>
<form>
<form
hx-trigger="submit"
hx-post="{{ action }}"
hx-swap="outerHTML"
hx-target="#student_card_form"
>
{% csrf_token %}
{{ form.as_p() }}
<button
hx-post="{{ action }}"
hx-swap="outerHTML"
hx-target="#student_card_form"
>
{% trans %}Go{% endtrans %}
</button>
<button>{% trans %}Go{% endtrans %}</button>
</form>
<h6>{% trans %}Registered cards{% endtrans %}</h6>

View File

@ -30,11 +30,13 @@
{{ user_subscription(customer.user) }}
<p>{% trans %}Amount: {% endtrans %}{{ customer.amount }} €</p>
<div
hx-get="{{ url('counter:add_student_card_fragment', counter_id=counter.id, customer_id=customer.pk) }}"
hx-trigger="load"
hx-swap="outerHTML"
></div>
{% if counter.type == 'BAR' %}
<div
hx-get="{{ url('counter:add_student_card_fragment', counter_id=counter.id, customer_id=customer.pk) }}"
hx-trigger="load"
hx-swap="outerHTML"
></div>
{% endif %}
</div>
<div id="click_form">