This has been a little tricky. I have followed a nice Ajax tutorial for rails but i kept getting the “Ajax is not defined” error in the javascript console. The solution is to include the prototype.js javascript file into your code. Simply write the following into your rhtml file:
<%= javascript_include_tag "prototype" %>
That’s all.
Hey dude,
Thanks for this tip – but….
Isn’t scriptaculous integrated into Ruby? why do we have to define it? that’s what I wondered.
It seems to be like the holy hand grenade. Using it twice is too many.
Whoops. Got my libraries mixed up.
but i thought for prototype to be used in any rhtml/jsp, one definitely has to include the javascripts in the head. does “prototype integrated into rails” mean we can use like a default library without including it???
From what i figured out no, you can’t use it directly. Prototype ingrated means that they use prototype in their code,
so you don’t have to download prototype separately and put it in your code, you only have to include it they way it’s on the post.
Hi, I tried it but for me still it is saying Ajax is not defined. I have invoked a popup window and from there now i am calling a javascript method that should then call an ajax method, but it says Ajax is not defined. Any clues??
Have you added the above mentioned
< %= javascript_include_tag "prototype" %>
in the rhtml file that displays the contents of your popup?
prototype.js should be included when you add But I’m still getting the same error.
The most wierd thing is that the error is raise when the application runs on mod_rails, but if the application runs on mongrel everything works just fine