mysterious-toddler-20573
09/17/2021, 9:59 PMwide-airport-20686
09/17/2021, 10:06 PMwide-airport-20686
09/17/2021, 10:09 PMmysterious-toddler-20573
09/17/2021, 10:40 PMbest-arm-55473
09/18/2021, 2:47 AMhtmx:configRequest
in the base.html an option? Matt Layman's guide here was helpful to me https://www.mattlayman.com/blog/2021/how-to-htmx-django/wide-airport-20686
09/18/2021, 5:42 PMwide-airport-20686
09/18/2021, 5:43 PMpython
class ImageDelete(LoginRequiredMixin, BaseDetailView):
http_method_names = ["delete"]
def get_object(self):
return get_object_or_404(Image, owner=self.request.user, id=self.kwargs["image_pk"])
def delete(self, request, *args, **kwargs):
self.object = self.get_object()
self.object.delete()
response = redirect(reverse('item_detail', kwargs={'pk': self.kwargs['pk']}))
response.status_code = 303
return response
wide-airport-20686
09/18/2021, 5:44 PMwide-airport-20686
09/18/2021, 5:44 PMmysterious-toddler-20573
09/18/2021, 6:11 PMwide-airport-20686
09/18/2021, 6:14 PMwide-airport-20686
09/18/2021, 6:15 PMmysterious-toddler-20573
09/18/2021, 6:22 PMwide-airport-20686
09/18/2021, 6:28 PMwide-airport-20686
09/18/2021, 6:28 PMcold-morning-35868
09/18/2021, 10:12 PMcold-morning-35868
09/19/2021, 5:11 AMImageDelete
above and seems to work fine on my side 😕 😮 (Using Matt Leyman's method of putting csrf in the request headers)white-garden-37887
09/19/2021, 6:16 PM<form action="." hx-ws="send">
<input type="number" name="input">
<button hx-ws="submit">Submit</button>
</form>
is there a way to clear input field after submit via htmx tag?mysterious-toddler-20573
09/19/2021, 8:32 PMmysterious-toddler-20573
09/19/2021, 8:34 PMwide-airport-20686
09/23/2021, 11:44 PMbrainy-grass-55742
09/25/2021, 8:52 PMhx-delete
to delete a row by passing hx-target="closest tr"
(default example on the HTMX website) and I send back a JsonResponse({"success": "row deleted"})
from the view, is there a way to get the JSON data to display somewhere else instead of replacing the space (row) just deleted by HTMX?
In jQuery, I typically do something like this $("#displayDiv").empty().append(done).fadeIn().delay(3000).fadeOut(1000);
inside success callback function after each successful delete operation.mysterious-toddler-20573
09/25/2021, 8:55 PMimportant-winter-64905
10/01/2021, 5:52 PMtd
tag. This is great because I can submit individual forms corresponding to a row and column index without submitting an entire row at one time. The problem is that the HTML snippet that is returned has a different CSRF tag once the form is submitted.
How do I return a code snippet with the same CSRF tag?
I'm thinking of using this little script to do that for me instead of doing it using the Django template. https://justdjango.com/blog/dynamic-forms-in-django-htmx#create-a-base-html-file
<script>
document.body.addEventListener('htmx:configRequest', (event) => {
event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
})
</script>
important-winter-64905
10/01/2021, 8:34 PMincalculable-scientist-18707
10/02/2021, 2:51 PMmysterious-toddler-20573
10/02/2021, 2:58 PMmysterious-toddler-20573
10/02/2021, 2:59 PMmysterious-toddler-20573
10/02/2021, 2:59 PMmysterious-toddler-20573
10/02/2021, 2:59 PM