saveTiles clean up listeners on close

This commit is contained in:
Azgaar 2021-09-25 17:31:25 +03:00
parent 2587a1643b
commit 3dea76777b
2 changed files with 5 additions and 6 deletions

View file

@ -32,7 +32,7 @@ function editMarker() {
$("#markerEditor").dialog({ $("#markerEditor").dialog({
title: "Edit Marker", title: "Edit Marker",
resizable: false, resizable: false,
position: {my: "center top+30", at: "bottom", of: element, collision: "fit"}, position: {my: "left top", at: "left+10 top+10", of: "svg", collision: "fit"},
close: closeMarkerEditor close: closeMarkerEditor
}); });

View file

@ -798,6 +798,9 @@ function openSaveTiles() {
status.innerHTML = ""; status.innerHTML = "";
let loading = null; let loading = null;
const inputs = document.getElementById("saveTilesScreen").querySelectorAll("input");
inputs.forEach(input => input.addEventListener("input", updateTilesOptions));
$("#saveTilesScreen").dialog({ $("#saveTilesScreen").dialog({
resizable: false, resizable: false,
title: "Download tiles", title: "Download tiles",
@ -819,17 +822,13 @@ function openSaveTiles() {
} }
}, },
close: () => { close: () => {
inputs.forEach(input => input.removeEventListener("input", updateTilesOptions));
debug.selectAll("*").remove(); debug.selectAll("*").remove();
clearInterval(loading); clearInterval(loading);
} }
}); });
} }
document
.getElementById("saveTilesScreen")
.querySelectorAll("input")
.forEach(el => el.addEventListener("input", updateTilesOptions));
function updateTilesOptions() { function updateTilesOptions() {
if (this?.tagName === "INPUT") { if (this?.tagName === "INPUT") {
const {nextElementSibling: next, previousElementSibling: prev} = this; const {nextElementSibling: next, previousElementSibling: prev} = this;