Accessing outer loop element from inner loop in JS part


#1

hi everyone,
i am confused in one logic here.
if i am using mutiple each lops and want to excess oouter loop element in the iunner loop is this posible. i have used {{…/entry1}}. this works great with Blaze but is there a way i can excess this value in js part.
let me explain a bit deeper with help of a exaple.

{{#each loop1}}
  {{#each loop2}}
          {{helper_function_that_returns_value}}
  {{/each}}
{{/each}}

loop1 returns 3 entry;
name='akhilesh’
age = 24
gender = ‘male’

loop2 returns 3 entry
name='kakz’
mobile= '1123456789’
city='newyork’
dob = ‘12 feb 2017’


 helper_function_that_returns_value(){
     var a1 = this.name;
 // a1 is going to return 'kakz', i want to access 'akhilesh'  and other entries in same table. Accessing values of outer loop  in inner loop.  
 }

What if i user more than two each loops? Is there any method we can still access values in blaze and JS.

thanks for anyone who is gonna put any effort here. last time when i got stuck in such problem @jamgold helped me . so thanks to him and if he can help me here, i will be greatfulll.


#2

I think this might work

{{#each l1 in loop1}}
  {{#each l2 in loop2}}
          {{helper_function_that_returns_value l1 l2}}
  {{/each}}
{{/each}}

#3

Yeah this is exactly why the Blaze Guide recommends using {{#each _ in _ }} by default


#4

Thanks @jamgold And @coagmano for replying. the answer was helpfull. Got what i was looking for.