Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
ES6 module loaded dynamically along with Fetched part doesn't execute when content is loaded again

I have a page that switches content using fetch API. Every content is accompanied with a js file. Some of them are type='module'. However although modules are working excellent during the first load, when I switch content (call a different fetch endpoint) and switch back again the corresponding script doesn't seem to work. When the whole page is changed (e.g. go to profile page and then again to main page) the scripts are working normally.

--- inside the main page the part that calls the content ---

...
    auth.fetch(partUri).then((resp) => {
            return resp.text().then(text => {
                
                $('.title > h2').text(titles[ch - 1]);

                $('#part-' + partNo).html(text);
                }
    
            });
          
    });
...

--- Inside the content's html file ---

...
<script> <--- this script is working after switching back
    new SimpleLightbox('.gallery-item a', {
        disableScroll: false
    });
</script>
<script type="module" src="js/part-3.js"></script> <--- this script is working only the first time
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda