Skip to content Skip to sidebar Skip to footer

Rails 4: Jquery .ready Not Firing

No solutions on stackoverflow seem to be working for my issue here, though I am likely missing something basic. I can't seem to get JQuery's .ready function to fire in my Rails 4 a

Solution 1:

First of all, I don't recommend adding any js code to application.js as that is a manifest file. Simply create a new file, for example, core.js.coffee and try

$ -> alert 'Hello World!'

Sprockets in Rails takes all your js / coffee files and puts them into a compressed and minified single file in production.


Solution 2:

I figured out a solution. It looks like my jquery.js file that I included in the assets folder was conflicting with the jquery gem. I deleted the jquery file, and changed the syntax to:

$( document ).ready(function() { alert("Hello, world!") });

Post a Comment for "Rails 4: Jquery .ready Not Firing"