Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda