Fix form not syncing due to HTMX
Django CI/CD / build-and-push (push) Successful in 2m38s Details

This commit is contained in:
Lukáš Kucharczyk 2023-11-16 19:03:16 +01:00
parent f5faf92ee0
commit a485237456
2 changed files with 2 additions and 0 deletions

View File

@ -59,6 +59,7 @@ class PurchaseForm(forms.ModelForm):
related_purchase_by_edition_url = reverse("related_purchase_by_edition")
self.fields["edition"].widget.attrs.update(
{
"hx-trigger": "load, click",
"hx-get": related_purchase_by_edition_url,
"hx-target": "#id_related_purchase",
"hx-swap": "outerHTML",

View File

@ -25,6 +25,7 @@ function setupElementHandlers() {
}
document.addEventListener("DOMContentLoaded", setupElementHandlers);
document.addEventListener("htmx:afterSwap", setupElementHandlers);
getEl("#id_type").onchange = () => {
setupElementHandlers();
};