You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The POST request is successfully sent to the server and a form element is sent back to replace the original using render_crispy_form() and HttpResponse(). However, after the replacement, the interactive features of django-jsonform stop working. What could be the problem?
The text was updated successfully, but these errors were encountered:
ErikKoinberg
changed the title
From dynamics not working after reloading it with HTMX
Form dynamics not working after reloading django-jsonform with HTMX
Feb 4, 2024
I understand now that I should use the built-in validation for this system, however, I am still curious how to make HTMX work with this. Even when using return render() instead of return HttpResponse() am I not getting it to work.
@ErikKoinberg, I think the issue might be due to the JavaScript being initialized only once on the original form. Since HTMX swaps out the form dynamically, the JavaScript needs to be reinitialized to apply to the new form content.
Since I am new to this library, I may not fully understand its inner workings. However, you can look into the HTMX documentation for ways to trigger JavaScript code after a swap. This might help you reinitialize the necessary components. Here are some relevant links from the HTMX documentation that could be useful:
I am using django-jsonform together with HTMX .
I have created a model that looks like this:
`class GroceryStore(models.Model):
That I am rendering using crispy-forms:
Form:
`class GroceryStoreForm(ModelForm):
Template:
{% load static %} {% load crispy_forms_tags %} {% crispy grocery_form %}
The POST request is successfully sent to the server and a form element is sent back to replace the original using render_crispy_form() and HttpResponse(). However, after the replacement, the interactive features of django-jsonform stop working. What could be the problem?
The text was updated successfully, but these errors were encountered: