Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails 3.2.8 & jQuery: Blank javascript function bodies?
    primarykey
    data
    text
    <p>developing my first Rails application here. Trying to get jQuery working in my views, which as I understand, should simply work 'out-of-the-box' with my current version of Rails 3.2.8.</p> <p>Here's what I got:</p> <ul> <li><p>A view called <em>register#index</em> (with a controller called 'register'):</p> <pre><code>&lt;head&gt; &lt;%= stylesheet_link_tag "application", controller.controller_name %&gt; &lt;%= javascript_include_tag "application", controller.controller_name %&gt; &lt;/head&gt; </code></pre></li> <li><p>Two JS files being loaded by this view: <em>application.js</em> and <em>register.js</em></p> <p><em>application.js</em>:</p> <pre><code>//= require jquery //= require jquery_ujs //= require twitter/bootstrap </code></pre> <p><em>register.js</em>:</p> <pre><code>$(document).ready(function(){ alert("Hello, jQuery!"); }); </code></pre></li> </ul> <p>When I load the page through my browser, I can see the jQuery.js files included, and my <em>register.js</em> loaded, which now has been converted to:</p> <pre><code>(function() { }).call(this); </code></pre> <p>The <code>alert()</code> call is missing (and doesn't trigger). Why is this blank? Is this a problem with my gem, or a problem with my jQuery syntax?</p> <p>Some additional things worth noting:</p> <ul> <li>Gemfile includes <code>jquery-rails</code>, and I've run <code>bundle install</code> and <code>rails g jquery:install</code></li> <li>Even if I put in jQuery other than <code>alert()</code>, the function body still shows up blank.</li> <li>I have cleared my caches between each test.</li> <li>There are no JavaScript errors reported by the browser (Chrome)</li> <li>This code is more or less copy/pasted directly from the jQuery tutorial.</li> </ul> <p><strong>EDIT</strong>: Added how my javascript tags are included in the page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload