I have a question regarding basic usage of Ajax/jQuery in Ruby On Rails 3.
I have read many Tutorials, but this Ajax thing is really complicated for me. jQuery isnt used any more and in newer papers were referred to “prototype”. And in some other papers you were referred to “Unobtrusive Javascript”… This all is really confusing for me. I didnt find any up-to-date “Ajax Beginner Howto for Ruby on Rails” – so maybe someone could help me here.
What i want to do, for example, is to create a Box with a static HTML Content in (it should display Contact- & Licence Information). I found this Question Ajax pop up box using Ruby on Rails which is exactly what i search (facebox seems to be perfect), but if i try to do it like:
<a href="remote.html" rel="facebox">text</a> (in my index.html.erb view)
(see http://defunkt.io/facebox/) and load the dependencies:
<link href="/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/facebox/facebox.js" type="text/javascript"></script> (in my application.html.erb view)
without loading jquery and with jquery from google. Default RubyOnRails Javascript is loaded additionally.
… it doesnt work. Sadly.
I there someone how could bring light into the Ajax Rails thing for me? Maybe white some little examples?
Thanks a lot!
To get you started, I suggest you to look into the following resources:
The first one is a railscasts-episode by Ryan Bates, which is a really great start.
The second one is an absolute beginners tutorial, which is admittedly not comletely flawless, but it should give you a headstart into the right direction.
To get a deeper insight you should check the following articles:
All those resources are available on the web for free. One last (very highly) recommendation though is the updated book “Agile Web Development with Rails” (partly) written by David Heinemeier Hansson himself.
It shows you how to use Ajax with jQuery within a working (little bit bigger) rails-application in a very straightforward and easy-to-follow manner.
Hope this helps
cheers