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

287
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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