Thursday 15 April 2010

How do I use jQuery in Ruby on Rails 3.2? -


I am a newbie in the Rail on Ruby and we have to know what we need to use in Ruby on Rails application JQuery

I have this in my watch page:

  & lt; Script type = "text / javascript" src = "https: // ajax .googleapis.com / ajax / libs / jQuery / 1.7.2 / jquery.min.js" & gt; & Lt; / Script & gt; & Lt;% = javascript_include_tag "Application"% & gt; & Lt; Script & gt; Warning ("Hussein") Warning ($ ('$ hussi'). Val ()) & lt; / Script & gt;   

This gives the first warning as expected, but for the second warning this '$' is not defined.

I have jquery-rails gem installed. / P>

The browser indicates that I have a mistake reference in my application.js file.

  requires jquery; Requires Jquery_ujs;   

I saw some file examples where they mention it like this:

  = jquery is required; = Required jquery_ujs;   

But raises an IDE error in my IDE by adding '='.

Add it to application.js:

  // Essentials Jquery // essential jquery_ujs   

and add it to your Gemfile:

  gem 'jquery-rails'   

Also make sure that you have this app in the layout:

  <% = Javascript_include_tag "app"%>   

Just a note: Avoid using tags in your code, move your javascript to your property folder.

No comments:

Post a Comment