title: Meteor: access this
body: <p>Multiple times in a row I've had the same problem with Meteor:</p>
  
  <p>I am in a function (e.g. Hook) and cant access 'this':</p>
  
  <pre><code>AutoForm.addHooks('aaForm', {
      before: {
          insert: function (insertDoc, updateDoc, currentDoc) {
              // 'this' is overwritten here
          }
      }
  });
  </code></pre>
  
  <p>Or even harder:
  I use '<a href="https://github.com/PeppeL-G/bootstrap-3-modal/blob/master/main.js" rel="nofollow">peppelg:bootstrap-3-modal</a>' </p>
  
  <p>I am currently on the route '/aa/<strong>ID_HASH</strong>' with </p>
  
  <pre><code>data = {
      name: "hello",
      _id: __ID_HASH__
  }
  </code></pre>
  
  <p>and at some point I call
      Modal.show("modal", {"modalTemplate": template});</p>
  
  <p>where 'modal' is</p>
  
  <pre><code>&lt;template name="modal"&gt;
      &lt;div class="modal fade"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  {{&gt; Template.dynamic template=modalTemplate}}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>and 'template' is the name of the template I want to render it in.
  In my case I render a quick form and want to access the original data object {name,_id} in the 'before' hook</p>
  
  <p>So my question is how do I access/pass parameters to functions that overwrite 'this'?</p>