Ah, I found my mistake!!!
I was just only adding JQuery in my view with <%=
javascript_include_tag “http://code.jquery.com/jquery-latest.js” %>,
but not in my application.html.erb. That means that the code in the
application.js had propably no JQuery access!
Ok remove this
javascript_include_tag “http://code.jquery.com/jquery-latest.js” %>,
google to your Gemfile and at this
gem “jquery-rails”
then in the console
bundle install
this will install jquery the right way
then go to config/application.rb
and verify that :defaults is made up of this
config.action_view.javascript_expansions[:defaults] = %w(rails jquery)
this like here is what tells rails what to output in the javascript_include_tag :defaults
line
now jquery is set up.
My problem now is that my other normal Rails Java Helpers (see
below )are not working anymore as intended!
<%= button_to ‘Destroy’, product, :confirm => ‘Are you sure?’, :method
=> :delete %>
That one is wotking, but there is no confirm pop up!!!
Is possible that you are have installed prototype which has similar syntax to that of jquery.
I notice you said ‘Java’ helpers, pay attention, javascript is not java, they have similar syntax but that’s it.
Now what version of rails are you using, this helper changed their out put in rails 3.x+ from that found in rails 2.x-.
I read something about JRails. Is that an option or is there another
way???
JRuby is not a javascript+ruby package is java with a ruby sintax, is a replacement for the ruby interpreter that lets Ruby run on the java virtual machine. Some gems are not compatible with jruby.
Remember, java and javascript are unrelated, the name javascript was give to javascript because java was popular back when javascript was been develop. Java is a general purpose programing language, javascript is a scripting language aimed mainly at the web.
read this also:
http://en.wikipedia.org/wiki/JavaScript
The deal with javascript and ‘the other way’ is that , since javascript was develop when the web was very young it has lots of short coming, so people start creating functions to deal with those short coming and eventually put them together to made a library, for example, to capture a the form with an id for filter without using any javascript library you would have to type this
document.getElementById(‘filters’)
as you can see that is a bit long, also if it were a class you would have to do this
document.getElementByClassName(‘show1’)
and if you have to capture a tag type
document.getElementByTagName(‘input’)
so many libraries have a function that replaces this with $( ) where $ is the name of the function. In jquery you distinguish what is that you want to capture by addin a #, a . or nothing.
the result is :
document.getElementById(‘filters’)
is
$(“#filters”)
document.getElementByClassName(‘show1’)
is
$(“.show1”)
and
document.getElementByTagName(‘input’)
is
$(‘input’)