BorisMoore/jsviews — Issue #20: Inside {{#each}} you can only access the data you're iterating over
Author: askerb
Created: 2011-12-09 09:45:39+00:00
State: open

Hi,
I really like JsRender/JsViews, but I'm puzzled about one thing.
When using {{#each}}, it seems I can only access data from the array I'm iteration over. In the example below I cannot access "CurrentValue" within the each iterator.

This is how my json data looks:
tasks = [
{
CurrentValue: { Id: 0, Description: "some value" },
ValidValues: [
{ Id: 0, Description: "some value" },
{ Id: 1, Description: "second value" },
{ Id: 2, Description: "third value" }
]
}]

Inside the template:

Acessing CurrentValue is no problem:
Value:{{=CurrentValue.Id}}

{{#each ValidValues}}
Inside the iterator i can no logner access CurrentValue
{{#if CurrentValue.Id == Id}} // Error: $data.CurrentValue is undefined.

{{=Description}}

{{else}}

{{=Description}}

{{/if}}
{{/each}}