-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathmodals_main.html
49 lines (44 loc) · 1.07 KB
/
modals_main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{% extends "base.html" %}
{% load static %}
{% block extrahead %}
<script defer src="{% static 'js/modals.js' %}"></script>
<link href="{% static 'css/modals.css' %}" rel="stylesheet">
{% endblock %}
{% block body %}
<h1>Monsters</h1>
{% block monster-list %}
<div
id="monster-list"
hx-get="."
hx-trigger="monsterCreated from:body"
hx-vals='{"use_block": "monster-list"}'
hx-target="#monster-list"
hx-swap="outerHTML"
>
{% if monsters %}
<table>
<tr>
<th>Name</th>
<th>Happy?</th>
</tr>
{% for monster in monsters %}
<tr>
<td>{{ monster.name }}</td>
<td>{{ monster.is_happy|yesno:"Yes,No" }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>There are no monsters</p>
{% endif %}
</div>
{% endblock %}
<button
hx-trigger="click"
hx-get="{% url 'modals_create_monster' %}"
hx-target="body"
hx-swap="beforeend"
>
Add a monster
</button>
{% endblock %}