Last active
July 5, 2020 05:28
-
-
Save parzibyte/ac5ceeafe70e9fa30aba8a347e26e681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", () => { | |
const $select = document.querySelector("#id_cliente"); | |
let lastSelectedIndex = $select.selectedIndex; | |
$select.addEventListener("click", function () { | |
lastSelectedIndex = $select.selectedIndex; | |
}); | |
$select.addEventListener("change", function (e) { | |
if (!confirm("Al cambiar de cliente se eliminará la lista de artículos. ¿Continuar?")) { | |
$select.selectedIndex = lastSelectedIndex; | |
return; | |
} | |
// Aquí el usuario sí ha aceptado, continúa con lo que harías normalmente | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment