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

142
Visualizações
Changing jinja template dynamically using Javascript

I am making a web application using flask and I am having issues solving a very specific problem.

In one of the pages, I am trying to use javascript in order to dynamically change part of the page to show different content. My problem is, that the new content I am trying to display resides in a different html file and I am trying to displaying using the jinja include template method. This is however not working as it is simply being recognized as text.

Some code to better showcase the issue: When Initially loading the page, the div that has the content that I want updated looks like this:

<div id="graph-div">
    {% include "test_performance.html" %}
</div> 

and my javascript looks like this:

selection =  document.getElementById('category');

if (selection.value === 'Overall Tests & Failures') {
    document.getElementById('graph-div').innerHTML = '{% include "test_failures.html" %}';
} else {
    document.getElementById('graph-div').innerHTML = '{% include "test_failures.html" %}';
}

When initially loading the page, the content renders successfully, however after running the script, the following happens:

Image

Does anyone have any idea if doing what I am trying is actually possible (and how) or whether I need to approach this differently?

I have done some research and the only relevant post I found was this however, the solution marked as correct did not work for me.

Thanks, George

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