Created
July 18, 2019 16:07
-
-
Save parzibyte/3fbf2c344957d7dadf9b9fd0be8ee73c 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
const confirmarEliminacion = evento => confirm("¿Está seguro? esta acción no se puede deshacer") || evento.preventDefault(); | |
document.addEventListener("DOMContentLoaded", function() { | |
/* | |
* Esperar a que se cargue el dom, buscar los <a> que tienen un icono de eliminar | |
* y agregar un callback. Es importante acceder a parentElement.parentElement porque si no, | |
* estaríamos agregando el listener al <i> en lugar del <a> | |
* */ | |
document | |
.querySelectorAll("a > span > i.fa.fa-trash") | |
.forEach(elemento => elemento.parentElement.parentElement.addEventListener("click", confirmarEliminacion)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment