Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!