1
0
mirror of https://github.com/django/django.git synced 2025-04-21 07:44:36 +00:00

Updated formset remove event listener- creates some sort of error but causes filter to reset

This commit is contained in:
DhanyaShah 2024-12-06 19:11:49 -05:00
parent 62e557d25a
commit f2c1baec44

View File

@ -326,12 +326,14 @@ Requires core.js and SelectBox.js.
});
document.addEventListener('formset:removed', function(e) {
const inlineElement = e.target; // The removed inline element.
const field_id = inlineElement.querySelector('select.filtered')?.id;
if (field_id) {
// Remove any references or event listeners related to the field_id.
const inlineElement = e.target;
const field = inlineElement.querySelector('select.filtered');
if (field) {
const field_id = field.id.replace('_from', ''); // Remove '_from' suffix if present
const fromBox = document.getElementById(field_id + '_from');
const toBox = document.getElementById(field_id + '_to');
// Remove elements if present
if (fromBox) fromBox.remove();
if (toBox) toBox.remove();
console.log(`Cleaned up SelectFilter for field_id: ${field_id}`);