title: Meteor.js - setting focus to form input field upon template refactor
body: <p>New to Meteor and appreciate any help - have been struggling with this one. So I have a template that is drawn conditionally:</p>
  
  <pre><code>{{#if creating}}
      &lt;form class="form-create"&gt; 
       &lt;input name="name" type="text" id="mainInput"&gt;
       &lt;button type="submit"&gt;Submit&lt;/button&gt;
       &lt;a class="cancel" href="#"&gt;Cancel&lt;/a&gt;
       &lt;/form&gt;
   {{else}}
     &lt;a class="create" href="#"&gt;Create&lt;/a&gt;
    {{/if}}
  </code></pre>
  
  <p>That works just fine - clicking the anchor link summons the form by way of the "CREATING" session reactive variable, cancel the form summons the anchor again.</p>
  
  <p>My issue is when the Form appears, I'd like to set the input (#mainInput) to focus. Now this code will work if I wire it up to a button or something (it sets the input to focus so I know the jquery works - for example:</p>
  
  <pre><code> "click .focusBtn": function(e, tpl) {
  
     tpl.$("#mainInput").focus();
     tpl.$("#mainInput").select(); //might as well select the entire thing too
  </code></pre>
  
  <p>},</p>
  
  <p>But, I can't get this focus to 'focus' upon a screen redraw from the anchor to the form! </p>
  
  <p>I've tried hooking it up in the session variable (Creating) code - so that everytime creating is changed (console.log I see the Creating switch from true to false, I validate Creating is true, call the focus from that helper block, but no change)</p>
  
  <p>I've also tried a tracker to the session var creating - like this, to no avail, focus isn't achieved:</p>
  
  <pre><code>Tracker.autorun(function () {
    var creating = Session.get('creating');
    console.log('Autorun is auto-running!');
    console.log(creating); 
  
    if (creating) {
         $('#mainInput').focus(); // I tried documentbyID, etc but nothing
    }
  }); 
  </code></pre>
  
  <p>I realize it might have something to do with Tracker, or maybe there's a "hook" i'm not aware of (I tried rendered template but this seems to only work upon initial creation, one time) I'm reading the guide now, but still new to this and any help / guidance is appreciated. Thanks!</p>