title: Jquery and CoffeeScript scrollTo with Rails and Haml
body: <p>I'm trying to perform a really simple task with <code>CoffeeScript</code> <code>Rails</code> and <code>Haml</code>. I havn't used <code>CoffeeScript</code> that much, but I want to give it a try. </p>
  
  <p>When the user presses a button I want the view to scroll to a certain div id. In the top of my page I have an Id like this:</p>
  
  <pre><code>#area_1
  </code></pre>
  
  <p>My links looks like this:</p>
  
  <pre><code>= link_to "Area", "#", id: "area_button_1"
  </code></pre>
  
  <p>In my automatically generated <code>CoffeScript</code> file I have a function that looks like this:</p>
  
  <pre><code>$ -&gt;
    scrollToArea = (button, area) -&gt;
      $(button).click -&gt;
        scrollTo(area, 800)
  </code></pre>
  
  <p>I try to call this method in one of my view files like this:</p>
  
  <pre><code>:javascript
    scrollToArea("#area_button_1", "#area_1") 
  </code></pre>
  
  <p>But this isn't working. Any ideas on what I'm doing wrong?    </p>