Open beeekey opened 1 year ago
My solution so far:
// here we setup a global event listener for the `formset:added` event (which is setup in `static\admin\js\autocomplete.js`)
// event to get triggered when adding a new django inline formset (by clicking the plus button below the inline formset)
(function($) {
$(document).ready(function() {
var els = document.getElementsByClassName("djn-add-handler");
const formUpdateEvent = new CustomEvent("formset:added", { "detail": "Dummy event" });
for (el of els) {
el.addEventListener("click", function () {
setTimeout(function(){
document.dispatchEvent(formUpdateEvent);
}, 250);
});
}
});
})(django.jQuery);
Could you provide more information so that I might try to reproduce this issue? We have a test to confirm whether autocomplete works, both for extra and newly added inlines, so I'll need to know what's different with your setup.
I have an Inline model as following:
When setting
extra=1
the autocomplete works for the first entry (works for all which are defined withextra
) , when adding another inline entry by clicking the+ add
button, the autocomplete field is empty. Comparing the html of these two elements, there are a lot of html tags missing.I am using Django 4.2