handsome-shampoo-48908
05/17/2023, 9:45 AMhtml
<div class="container mx-auto mt-5">
    <header class="d-flex align-items-center gap-2 mb-5">
        <img src="https://cdn-icons-png.flaticon.com/128/2666/2666436.png" alt="ToDo List">
        <h1 class="mb-0">To Do List</h1>
    </header>
    <hr>
    <br>
    <div class="row justify-content-around">
        <div class="card col-sm-6 col-md-4 col-lg-4 mb-5">
            <h5 class="card-header">Collections</h5>
            <div class="card-body">
                <nav id="collections" class="list-group">
                    {% for collection in collections %}
                    {% include 'tasks/collection.html' with collection=collection %}
                    {% endfor %}
                </nav>
                    <form method="POST" class="d-flex gap-2 mt-2">
                        {% csrf_token %}
                        {{ form_collection.name }}
                        <button class="btn btn-success"
                                hx-post="{% url 'add-collection' %}"
                                hx-target="#collections"
                                hx-swap="beforeend"
                                type="submit">Add
                        </button>
                    </form>
            </div>
        </div>handsome-shampoo-48908
05/17/2023, 9:45 AMhtml
      <div class="card col-sm-6 col-md-6 col-lg-6 mb-5">
              <h5 class="card-header">Tasks</h5>
            <div class="card-body">
                <form method="POST" name="task-form" class="d-flex gap-2 mt-2" id="task_form">
                    {% csrf_token %}
                    {{ form_task.description }}
                    <button class="btn btn-success"
                            hx-post="{% url 'add-task' %}"
                            hx-target="#tasks"
                            hx-vals='js:{collection: getCollectionFromURL()}'
                            hx-swap="beforeend"
                            type="submit"
                    >Add
                    </button>
                </form>
                <section id="tasks-container">
                    {% include 'tasks/tasks.html' with tasks=tasks collection=collection %}
                </section>
            </div>
        </div>
    </div>
</div>handsome-shampoo-48908
05/17/2023, 9:45 AMhtml
<script>
    document.body.addEventListener("htmx:afterRequest", (event) => {
        document.querySelector(".reset-field-collection-form").value = '';
    })
    document.body.addEventListener("htmx:afterRequest", (event) => {
        document.querySelector(".reset-field-task-form").value = '';
    })
    document.body.addEventListener("htmx:responseError", (event) => {
        alert(evt.detail.xhr.responseText);
    })
    function getCollectionFromURL() {
        let url = new URL(window.location.href);
        let searchParams = url.searchParams;
        return searchParams.get("collection");
    }
    document.body.addEventListener('htmx:configRequest', (event) => {
        event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
    })
</script>mammoth-family-48524
05/17/2023, 10:08 AMwhite-motorcycle-95262
05/17/2023, 2:14 PMhx-change{% include 'widgets/widget_name.html' %}hx-<form
  id="control-panel
  hx-get="/widgets"
  _="
  init
    set widgets to {}
    for widget in <[data-widget]/>
      set widgets[widget's @id] to widget's @data-widget
    end
    set my @hx-vals to widgets as JSON
  end
>[...]</form>data-widgetbrave-dog-98297
05/17/2023, 9:27 PMwhite-motorcycle-95262
05/17/2023, 11:30 PMbrave-dog-98297
05/17/2023, 11:38 PMwhite-motorcycle-95262
05/17/2023, 11:40 PMplain-kangaroo-26043
05/19/2023, 5:18 PMgray-rocket-3571
05/20/2023, 4:16 PMhappy-microphone-42295
05/23/2023, 6:21 PMwhite-motorcycle-95262
05/24/2023, 1:00 PMpy
<form
  hx-get="/my_url/"
  hx-trigger="change"
>
  <select id="id_region" name="region">[...]</select>
  <select id="id_timespan" name="timespan">[...]</select>
</form>/my_url/[region.value]/[timespan.value]/py
<form
  hx-get="/my_url"
  hx-trigger="customChange"
  _="
    on change
      set my @hx-get to `${@hx-get}/${#id_region's value}/${#id_timespan's value}`
      trigger customChange on me
    end
  "
>[...]</form>great-cartoon-12331
05/24/2023, 3:56 PM/my_url/?region=[region.value]Γpan=[timespan.value]white-motorcycle-95262
05/24/2023, 4:05 PMlimited-teacher-83117
05/24/2023, 4:13 PMwhite-motorcycle-95262
05/24/2023, 4:16 PM/dashboard/texas/current//dashboard?region=texasΓpan=currentwhite-motorcycle-95262
05/24/2023, 4:17 PMlimited-teacher-83117
05/24/2023, 4:24 PMlimited-teacher-83117
05/24/2023, 4:25 PMgreat-cartoon-12331
05/24/2023, 4:26 PMwhite-motorcycle-95262
05/24/2023, 4:32 PM/dashboard/texas/currentgreat-cartoon-12331
05/24/2023, 4:34 PM/currentwhite-motorcycle-95262
05/24/2023, 4:36 PM/dashboard/texas/current/great-cartoon-12331
05/24/2023, 4:37 PM/currentwhite-motorcycle-95262
05/24/2023, 4:39 PM/blah/#element_idgreat-cartoon-12331
05/24/2023, 4:42 PMididlimited-teacher-83117
05/24/2023, 4:46 PMwhite-motorcycle-95262
05/24/2023, 4:46 PMlimited-teacher-83117
05/24/2023, 4:47 PM