title: Meteor Select Box - mark option as selected depending on data context
body: <p>I have been trying to figure out how to set the 'selected' attribute on an option within a select box and have fallen short today. Any help would be appreciated.</p>
  
  <p><strong>What I'm trying to accomplish:</strong>
  When a user chooses an option and hits submit, the data saves to a new mongo document and the new entry is shown on the screen (this part works). Upon browser refresh, the state is lost (due to no selected attribute being set) and the select box goes back to the first option. I need to figure out how to set the selected state depending on the value the user has saved on that particular document. On this page there are many of the same select boxes allowing the user to choose different options for other entries.</p>
  
  <p><strong>References (tried to implement with no luck):</strong></p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/24650658/check-for-equality-in-spacebars">Check for equality in Spacebars?</a></p></li>
  <li><p><a href="https://github.com/meteor/meteor/wiki/Using-Blaze#conditional-attributes-with-no-value-eg-checked-selected" rel="nofollow noreferrer">https://github.com/meteor/meteor/wiki/Using-Blaze#conditional-attributes-with-no-value-eg-checked-selected</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/26025574/meteor-js-how-can-i-indicate-checked-or-selected-in-the-templating-system">How do I indicate &#39;checked&#39; or &#39;selected&#39; state for input controls in Meteor (with spacebars templates)?</a></p></li>
  </ol>
  
  <p><strong>select box template:</strong></p>
  
  <pre><code>&lt;template name="tEdit"&gt;
  &lt;div class="form-group"&gt;
    &lt;div class="controls"&gt;
      {{&gt; fFEdit}}
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p><strong>select box option template:</strong></p>
  
  <pre><code>&lt;template name="fFEdit"&gt;
    &lt;select class="form-control" name="fFSelect"&gt;
      {{#each fFSelect}}
        &lt;option value="{{fId}}"&gt;{{fF}}&lt;/option&gt;
      {{/each}}
    &lt;/select&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p><strong>setting data context</strong></p>
  
  <pre><code>Template.fFEdit.helpers({
    fFSelect: function() {
      var fFArray = [
        { fF: "foo", fId: 0 },
        { fF: "bar", fId: 1 },
        { fF: "buzz", fId: 2 }
      ];
      return fFArray;
    }
  });
  </code></pre>