title: JS and Rails site wide announcements
body: <p>Tried doing <a href="http://davidwparker.com/2008/09/17/site-wide-announcements-in-rails-using-jquery-jgrowl/" rel="nofollow noreferrer">http://davidwparker.com/2008/09/17/site-wide-announcements-in-rails-using-jquery-jgrowl/</a></p>
  
  <p>Am really bad with JS.  Think I am messing up on the last part where it says "This code goes in your application.js file (somewhere in $(function){ //here })"</p>
  
  <p>Am I not suppose to do a link_to_function and create a function with this code that references that link?  </p>
  
  <p>Really lost on this one.</p>
  
  <p>Updated - </p>
  
  <p>application.js looks like</p>
  
  <pre><code>$(document).ready(function() {
      $.jGrowl.defaults.closer = true;
        $("#announcements_box").css("display", "none");
        $("#announcements_box .announcement").each(function(){
          $jQuery.jGrowl(this.textContent,{ sticky:true, close:function(e,m,o){hide_announcements();} });
        });
  
   });
  
  function hide_announcements(){
      $.get(
        '/hide_announcements'
      );
  
      $("#announcements_box").fadeOut();
      return false;
    }
  </code></pre>
  
  <p>And my application.html.erb has</p>
  
  <pre><code>&lt;% unless current_announcements.empty? %&gt;
  &lt;div id="announcements_box"&gt;
  &lt;% for announcement in current_announcements %&gt;
      &lt;div id="announcement_&lt;%= announcement.id.to_s %&gt;"  class="jGrowl"&gt;
      &lt;%= announcement.message %&gt;
      &lt;%= link_to "Hide Annoucements", hide_announcements_path, :id =&gt; 'hideAnn'%&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>