prevent scroll position from being lost when updating servings

This commit is contained in:
Khaïs COLIN 2025-10-19 13:57:14 +02:00
parent e05a4d0ccd
commit 12a040fe87
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 45 additions and 9 deletions

View file

@ -1,4 +1,4 @@
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
<div style="border: 1px solid black; margin: 1em; padding: 1em;" id="food-{{ food.id }}">
<div style="text-align: center;">
<p>
<b>{{ food.name }}</b>
@ -15,9 +15,14 @@
<br>
<form method="post">
<div style="text-align: center;">
<button formaction="/decrease/{{ food.id }}" style="width: 40%; height: 3em;" {% if food.actual_servings <=0 %}
disabled {% endif %}>-</button>
<button formaction="/increase/{{ food.id }}" style="width: 40%; height: 3em;">+</button>
<button hx-post="/decrease/{{ food.id }}" hx-target="#food-{{ food.id }}" hx-swap="outerHTML"
style="width: 40%; height: 3em;" {% if food.actual_servings <=0 %} disabled {% endif %}>
-
</button>
<button hx-post="/increase/{{ food.id }}" hx-target="#food-{{ food.id }}" hx-swap="outerHTML"
style="width: 40%; height: 3em;">
+
</button>
</div>
</form>
</div>

View file

@ -2,6 +2,7 @@
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">