title: Meteor: how to access parent properties within nested templates?
body: <p>I am getting started with Meteor, and adapting the <a href="http://meteor.com/examples/todos" rel="nofollow noreferrer">todo example</a> to include nested tag groups. I have the following HTML, which outputs each name of each tag group, plus the list of tags in that each group: </p>
  
  <pre><code>  &lt;template name="tag_filter"&gt;
      {{#each tag_types }}
        {{ tag_name }}
        {{#each values }}
          &lt;div data-taggroup="{{ ../tag_name }}"&gt;
          {{ name }} ({{ count }})
          &lt;/div&gt;
        {{/each}} 
      {{/each}}
  &lt;/template&gt;
  </code></pre>
  
  <p>My question is this: how do I adapt the event handler for clicks on the tags to access the value of the parent group's <code>tag_name</code>? (i.e. the data from the outer each loop). </p>
  
  <p>Currently I have the code below, but <code>this</code> object only gives me access to <code>name</code> and <code>count</code>. </p>
  
  <pre><code>Template.tag_filter.events({
    'mousedown .tag': function () {
      console.log('tag mousedown', this);
      // How do I get the value of tag_name?
    }
  });
  </code></pre>
  
  <p>As you can see, I've used <a href="http://handlebarsjs.com/#paths" rel="nofollow noreferrer">Handlebars parent paths</a> to add a <code>data-taggroup</code> attribute containing the name, but I'm not sure how to access that from within the event handler. </p>
  
  <p>I think <a href="https://stackoverflow.com/questions/10654255/nested-templates-finding-parent">this question</a> is related, but I don't understand the OP's solution (partly because I'm not using Coffeescript). There's also an <a href="https://github.com/meteor/meteor/issues/147" rel="nofollow noreferrer">closed Meteor issue</a> which is related. </p>