Add early return for movingDivs click handler

This commit is contained in:
Cohee
2024-09-27 20:25:09 +03:00
parent 061ed1db65
commit 53dc8702c3

View File

@@ -26,9 +26,11 @@ let paginationVisiblePages = 10;
let paginationMaxLinesPerPage = 2; let paginationMaxLinesPerPage = 2;
let galleryMaxRows = 3; let galleryMaxRows = 3;
// Remove all draggables associated with the gallery
$('#movingDivs').on('click', '.dragClose', function () { $('#movingDivs').on('click', '.dragClose', function () {
const relatedId = $(this).data('related-id'); // Get the ID of the related draggable const relatedId = $(this).data('related-id');
$(`#movingDivs > .draggable[id="${relatedId}"]`).remove(); // Remove the associated draggable if (!relatedId) return;
$(`#movingDivs > .draggable[id="${relatedId}"]`).remove();
}); });
const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved'; const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved';