From 41b969d5493a8739bfdd919f387d9da04bf52ca8 Mon Sep 17 00:00:00 2001 From: Marco Bonetti Date: Fri, 10 Nov 2023 10:42:41 +0100 Subject: [PATCH] fix: address failing gulp ci jobs. Fixes #1436 (#1437) --- filer/static/filer/js/addons/dropzone.init.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/filer/static/filer/js/addons/dropzone.init.js b/filer/static/filer/js/addons/dropzone.init.js index d3c7ff67c..fefe90105 100644 --- a/filer/static/filer/js/addons/dropzone.init.js +++ b/filer/static/filer/js/addons/dropzone.init.js @@ -163,7 +163,8 @@ djQuery(function ($) { // Handle initialization of the dropzone on dynamic formsets (i.e. Django admin inlines) $(document).on('formset:added', function (ev, row) { - if(ev.detail && ev.detail.formsetName) { + var dropzones, rowIdx, row_; + if (ev.detail && ev.detail.formsetName) { /* Django 4.1 changed the event type being fired when adding a new formset from a jQuery to a vanilla JavaScript event. @@ -172,16 +173,17 @@ djQuery(function ($) { In this case we find the newly added row and initialize the dropzone on any dropzoneSelector on that row. */ - let rowIdx = parseInt( + + rowIdx = parseInt( document.getElementById( 'id_' + event.detail.formsetName + '-TOTAL_FORMS' ).value, 10 ) - 1; - let row_ = document.getElementById(event.detail.formsetName + '-' + rowIdx); - var dropzones = $(row_).find(dropzoneSelector) + row_ = document.getElementById(event.detail.formsetName + '-' + rowIdx); + dropzones = $(row_).find(dropzoneSelector); } else { - var dropzones = $(row).find(dropzoneSelector); + dropzones = $(row).find(dropzoneSelector); } dropzones.each(createDropzone);