This.data from #each-iteration

Hi, I got help with this {{each}}-iteration a while back.

    {{#each room in channels}}
        <form class="enterRoom">
            <button type="submit" class="roomJoin">
                <b>{{room.name}}</b>  
                <img src="{{room.roomBanner}}" alt=".">
                <input type="hidden" value="{{room.name}}" name="name">
            </button>            
                <div class="inRoom"> 
                    {{#each name in room.inRoom}} 
                        <a href="/c/{{name}}" target="_blank">{{name}}</a> 
                    {{/each}}
                </div> 
        </form>
   {{/each}}

It works great. But I don’t seem to find a way of accessing the data from this iteration as I used to.
To get the name for example I would just do this.name But here it doesn’t seem to apply. I took a long look at the Spacebars and Blaze API but it couldn’t find a specific example.

I tried this.room.name but this will throw an error.

Could someone explain to me how I would access the data in this scenario? Thanks for any help.

When using each room in, this is scoped to the parent, so you should neither use this.name, nor this.room.name, but simply room.name.


'submit .enterRoom'(event) {
  event.preventDefault();
  
  const char = Session.get('activeChar');
  const target = event.target;
  const name = target.elements.name; 
  const isClosed = room.isClosed; // room.name example here

  if(isClosed == true) {
    alert("Closed");
    return;
  } else { 

    Meteor.call('inRoom.push', name.value, char, (error) => { if(error) {alert(error.reason);} });

    Session.set('room', name.value);
 
    Meteor.call('charactersRoom.update', char, name.value, (error) => { 
      if (error) { 
        alert(error.reason); } 
      else {
        FlowRouter.go('/room/'+name.value); 
      }
  
  });

}
   }

If I use it like that it will give this error though:

chat.js:86 Uncaught ReferenceError: room is not defined
    at Object.submit .enterRoom (chat.js:86)
    at blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:3818
    at Function.Template._withTemplateInstanceFunc (blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:3769)
    at Blaze.View.<anonymous> (blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:3817)
    at blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:2617
    at Object.Blaze._withCurrentView (blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:2271)
    at Blaze._DOMRange.<anonymous> (blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:2616)
    at HTMLFormElement.<anonymous> (blaze.js?hash=51f4a3bdae106610ee48d8eff291f3628713d847:863)
    at HTMLDivElement.dispatch (modules.js?hash=8331598f8baf48556a442a64933e9b70b778274a:9685)
    at HTMLDivElement.elemData.handle (modules.js?hash=8331598f8baf48556a442a64933e9b70b778274a:9492)

Did I forget to include something on that event in order to get access?