title: Simple jQuery not working in Rail 3.2
body: <p>This one has had me going for a couple of hours now. Any help would be appreciated, let me know if I can provide any more information.</p>
  
  <p>I am trying to get some basic jQuery working in my Rails 3.2 application. The jQuery in question is to provide an action on a button press (at the moment, just an alert dialog to know it's working).</p>
  
  <p><strong>app/views/orders/index.html.erb</strong></p>
  
  <pre><code>...
  
  &lt;button type="button" class="btn" id="button"&gt;My button&lt;/button&gt;
  
  ...
  </code></pre>
  
  <p>I have tried a number of variations for the jQuery/JS code, including...</p>
  
  <p><strong>apps/assets/javascripts/orders.js</strong></p>
  
  <pre><code>$('#button').click(function() {
      alert("Test message");
  });
  </code></pre>
  
  <p>.</p>
  
  <pre><code>$(document).ready(function() {
      $('#button').click(function() {
          alert("Test message");
      });
  });
  </code></pre>
  
  <p>.</p>
  
  <pre><code>$(document).ready(function() {
      $('#button').button();
      $('#button').click(function() {
          $(this).button('loading');
      });
  });
  </code></pre>
  
  <p>Some points to note:</p>
  
  <ul>
  <li>This is running in the development env</li>
  <li>The JS file is showing up in the source and in the Chrome network/resources panel without errors.</li>
  <li>I've tried re-ordering my application.js file.</li>
  <li>I am not adept with CoffeeScript yet, but am willing to try a CoffeeScript based solution.</li>
  <li>Chrome reports an error in Morris.</li>
  </ul>
  
  <p>My <strong>app/assets/javascripts/application.js</strong> for reference</p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require raphael
  //= require morris
  //= require bootstrap
  //= require_tree .
  </code></pre>
  
  <p>Any suggestions on steps to take to track down this bug would be very helpful!</p>
  
  <hr>
  
  <p><strong>Updates</strong></p>
  
  <p>Tried the following CoffeeScript solution with no luck.</p>
  
  <pre><code>jQuery -&gt;
      jQuery('#button').click -&gt;
          alert("Test msg")
  
  // ... which generates ...
  
  (function() {
  
    jQuery(function() {
      return jQuery('#jamcake').click(function() {
        return alert("You have cake?");
      });
    });
  
  }).call(this);
  </code></pre>
  
  <p>Tried changing button to a link, to no avail.</p>
  
  <p>Tried going back to basics, the following works.</p>
  
  <pre><code>alert("Hello");
  </code></pre>
  
  <p>However, the following does not...</p>
  
  <pre><code>$(document).ready(function() {
      alert("Hello there");
  });
  </code></pre>