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

285
Visualizações
Variables in javascript + jinja2

I'm not good in javascript. I have google charts with data. And I need to add data via loop in javascript:

for (let i = 0; i < 3; i++) {
    data.addRow(
        ['{{list[i][0]}}',
        { v: {{list[i][1][0]}}, f: '{{list[i][1][1]}}' }]
        );
}

But it wrote me an error:

UndefinedError

jinja2.exceptions.UndefinedError: list object has no element Undefined

Can you advice me please, what I can do with it?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I'm not too familiar with the Google Charts API, but from the looks of it, you have a syntax error since you're literally passing the string '{{list[i][0]}}' to the data.addrow() method.

Try this instead and let me know if it works:

for (let i = 0; i < 3; i++) {
  data.addRow([
    list[i][0],
    {
      v: list[i][1][0],
      f: list[i][1][1]
    }
  ]);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I have found the answer. Try like this:

{% for i in range(list|length) %}
    data.addRow(
        ['{{list[i][0]}}',
        { v: {{list[i][1][0]}}, f: '{{list[i][1][1]}}' }]
        );
{% endfor %}

It's no javascript, I know. But helped me to solve the problem.

about 4 years ago · Juan Pablo Isaza Relatório
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