I am having trouble getting jQuery to work on Ruby on Rails 3.2.13. I have looked at tutorials, searched youtube, etc. and I still can\'t get it to work.
More specifica
Jquery automate in Rails 3.2.13, see on your Gemfile, if you have gem 'jquery-rails'
on your Gemfile, you should be using 'application'
, without 'jquery-1.10.1.js'
, jquery-rails latest version using jQuery 1.10.1
see here
<%= javascript_include_tag :application %>
This will load the app/assets/javascript/application.js
file to load all your other javascript files on app/assets/javascript
folder, including jQuery:
//= require jquery
//= require jquery_ujs
//= require_tree .
$(document).ready(function() {
alert('Thanks for visiting!');
});
If you want use JQuery UI, you could use jquery-ui-rails
gem https://github.com/joliss/jquery-ui-rails
In your Gemfile, add:
gem 'jquery-ui-rails'
and run bundle install
read here for usage
Check your browser's console for any load error. It seems that you are not deploying the javascript, so it's not loaded.
Either use
<%= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" %>
or have a copy of the file you are serving in any of
/lib/assets/javascripts
/vendor/assets/javascripts
/app/assets/javascripts