title: Best way to find (i.e. set CSS) on DIV in table created by {{#each}} in Meteor?
body: <p>I have this code working but wondering if I'm doing it the long way. Is there a more efficient way? I was hoping for a 1 line of code solution.</p>
  
  <p>I want to change the color of a single DIV in a table created from a {{#each}} in Handlebars template. I came up with this callback, so every time isSharedByMe (which is a field in a Collection) becomes true, the templates reactivity sets the CSS color to green:</p>
  
  <pre><code>Template.showRepost.rendered = function () {
  
    if (this.data.isSharedByMe) {
       $( this.find('.repost') ).css( {'color': 'green'} );
        }
  
    return; // I like to explicitly show a return value so people know 
            // I'm not returning any specific value on purpose. 
            // Not sure if this kills efficiency (separate topic).
  };
  </code></pre>
  
  <p>The Handlebars template is simple, I call this as a partial from my main template that has the {{#each posts}} call which produces the table:</p>
  
  <pre><code>&lt;template name="showRepost"&gt;
      &lt;a href="#" class="repost"&gt;{{show_repost_txt}}&lt;/a&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>{{show_repost_txt}} just shows returns text like, "Share", or "Already Shared". </p>
  
  <p>This code above works, but what I was hoping for was to have 1 jQuery type line in my show_repost_txt helper to set the CSS color at the same time as changing text to "Already Shared". </p>
  
  <p>But I could figure out how to set ONLY the current class .repost, since this.find is not available in custom template helpers, but is available in the .rendered callback (along with event handlers). I tried this jQuery with no luck:</p>
  
  <pre><code>Template.showRepost.show_repost_txt = function () {
      if (this.isSharedByMe) {
  
          // Type $(this) in the Browser console 
          // (it's the jQuery call to the DOM window object, 
          // I just can't figure out how to get the specific DIV I need.
  
          $(this).find('.repost').css( {'color': 'green'} );
  
          return "Already shared.";
      }
  };
  </code></pre>