title: How to Hide an Element using Jquery and Coffeescript in Rails?
body: <p>I would like to hide an element in a page on my Rails site, but I'm not yet that familiar with Jquery or Coffeescript. </p>
  
  <p>This code works in the console:</p>
  
  <pre><code>$('#TheButton').click(function(){$('#TheText').toggle()});
  </code></pre>
  
  <p>I then <a href="http://js2coffee.org/" rel="nofollow">converted</a> it to Coffescript:</p>
  
  <pre><code>$("#TheButton").click -&gt;
    $("#TheText").toggle()
  </code></pre>
  
  <p>But it doesn't work on my Rails page. How do I fix it? Below is the generated javascript file:</p>
  
  <pre><code>(function() {
  jQuery(function() { 
  # stuff... 
    });
  
    $('form').on('click', '.add_fields', function(event) {
    # stuff... 
    });
  
    $("#TheButton").click(function() {
      return $("#TheText").toggle();
    });
  
  }).call(this);
  </code></pre>