bland-coat-6833
02/17/2022, 9:51 PMbland-coat-6833
02/17/2022, 9:52 PMplain-kangaroo-26043
02/17/2022, 9:55 PMbland-coat-6833
02/17/2022, 10:02 PMfresh-controller-36545
02/17/2022, 10:04 PMfresh-controller-36545
02/17/2022, 10:04 PMfresh-controller-36545
02/17/2022, 10:04 PMfresh-controller-36545
02/17/2022, 10:05 PMbland-coat-6833
02/17/2022, 10:06 PMbland-coat-6833
02/17/2022, 10:07 PMbland-coat-6833
02/17/2022, 10:08 PMfresh-controller-36545
02/17/2022, 10:09 PMfresh-controller-36545
02/17/2022, 10:09 PMimportant-winter-64905
02/18/2022, 7:35 PMif value < 7:
<<do green swap>
else:
<<do red swap>>
HTML snippet:
<td class="update_flash" id="abc_this" nowrap="nowrap">
<input hx-target="#abc_this" hx-swap="outerHTML swap:0s"
class="form-control form-control-sm" type="number"
name="nameabc" value="0.00" step="0.5"
hx-post="/projects/update" hx-trigger="change delay:0.1s">
</td>
my CSS:
td.update_green.htmx-settling {
background: #36842d;
}
td.update_red.htmx-settling {
background: #842d2d;
}
hundreds-camera-24900
02/18/2022, 9:37 PMhundreds-camera-24900
02/18/2022, 9:37 PMhundreds-camera-24900
02/18/2022, 9:38 PMif value < 7:
flash_color = 'update_green'
else:
flash_color = 'update_red'
-----------------
template:
<td class="update_flash {{flash_color}}" id="abc_this" nowrap="nowrap">
...
</td>
shy-refrigerator-51928
02/19/2022, 3:43 AMshy-refrigerator-51928
02/19/2022, 3:43 AMshy-refrigerator-51928
02/19/2022, 3:45 AM<form hx-post="{% url 'notecards:create' %}" hx-target="#notecards-list-group" hx-indicator=".htmx-indicator" hx-swap="afterbegin">
<div class="modal-body">
{% crispy form %}
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary"></input>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Cancel</button>
</div>
</form>
shy-refrigerator-51928
02/19/2022, 3:45 AMshy-refrigerator-51928
02/19/2022, 3:45 AMdef notecard_create(request):
template_name = 'notecards/hx/notecard_create_form_hx.html'
form = NoteForm(request.POST or None)
if request.method == 'POST':
if form.is_valid():
notecard = form.save()
template_name = 'notecards/hx/notecard_item_hx.html'
context = {'notecard': notecard}
return render(request, template_name, context)
context = {'form': form}
return render(request, template_name, context)
blue-gold-89534
02/19/2022, 1:15 PMblue-gold-89534
02/19/2022, 1:16 PMhtml
{% if form.errors %}
{% for error in form.errors %}
{% if error == "number" %}
<span class="text-danger">number exists</span>
{% endif %}
{% endfor %}
{% endif %}
{% for error in form.non_field_errors %}
<span class="text-danger">{{ error }}</span>
{% endfor %}
blue-gold-89534
02/19/2022, 1:16 PMimportant-winter-64905
02/20/2022, 8:52 PMclass="update_flash"
to start and when I do the HTMX swap it includes the same class which causes the flash to occur. I want to have the option to have it flash for two different colors now though. Green be that the submission was accepted and red meaning the submission was not accepted.hundreds-camera-24900
02/20/2022, 8:55 PM<td class="update_flash {{flash_color}}" id="abc_this" nowrap="nowrap">
work?hundreds-camera-24900
02/20/2022, 8:57 PMhundreds-camera-24900
02/20/2022, 8:58 PMhundreds-camera-24900
02/20/2022, 8:58 PM