blueimp/JavaScript-Templates

Array: can't loop through loop

Closed this issue · 1 comments

I have JSON structure:

{
"prices":[
{
"name": "Market 1",
"rows":[
{
"name": "test1",
"price": "4,25",
"rate": "+0,05"
},
{
"name": "test2",
"price": "4,12",
"rate": "+0,02"
}
]
},
{
"name": "Market 2",
"rows":[
{
"name": "test1",
"price": "4,25",
"rate": "+0,05"
},
{
"name": "test2",
"price": "4,12",
"rate": "+0,02"
}
]
}
]}

In my template i want to control all objects like:

{% for (var i=0; i<o.prices.length; i++) { %}
{%=o.prices[i].name%}

{% for (var j=0; j<o.prices[i].rows.lenght; j++) { %}
       show me something
   <span class="tb-txt">{%=o.prices[i].rows[j].name%}</span>
{% } %}

{% } %}

The first loop works, i see the name of each object.. but the 2nd loop doesnt work, i get no errors in the console, but it's now showing up. 'Show me something' isn't visible either.

Is this a bug?

Solved, typo! srry.. lenght vs length