I Eat Rainbows

30.12.2006

jQuery on Rails

Filed under: IRC, joR, katz, prototype, rails, steve, technology — Sohum @ 00.13.00 (050)

So, I really like jQuery and it’s clever extensions of bad old javascript. So, obviously, I’ve been looking at ways to integrate it with Ruby on Rails.
Now, me being a RoR newbie, I didn’t realize that it has it’s very own ajax-y extension to Javascript, namely, Prototype. And while I’m sure it’s very powerful and extensible and all that, my thoughts on it can be summed up in a quote from Yehuda Katz’s excellent blog post on this topic:

In fact, the difference in sensibilities [between Prototype and jQuery] is very similar to the difference in sensibilities between Java and Ruby, so it’s ironic that the Rails community has embraced Prototype so completely.

Ya.

So, of course, I now need to find a way to integrate jQuery with Rails. Katz’s jQuery on Rails project mentioned in the above post seemed promising, but I couldn’t find any live examples anywhere. So I turned to the always,-well-not-really-but-usually useful IRC.
stevenbristol on #jQuery said that no, no ones’s sure of what happened to joR (that abbreviation, as far as I can tell, is new. It should be interesting if it takes off in the same way RoR did.) He walked me through getting jQuery and Prototype to play nicely, and pointed me to his (brand-spanking) new blog, http://b.lesseverything.com/. As of posting, it has exactly one post, which is his introduction. He says those steps for getting jQuery to play nicely with Prototype will be posted there in a few days, so I won’t steal his thunder.

Anyway, I have just committed revision 12 of my ITGS project, now with jQuery, a cleaned up stylesheet, and a global application layout.

To finish off, some very basic jQuery goodness!

[Edit] WordPress doesn’t allow me to use Javascript. I understand their reasons, but still…

[Edit*2] Part two of this saga is at jQuery on Rails, pt 2

7 Comments »

  1. Hey,

    Just FYI: I’m still working on jQuery on Rails. I got a little derailed due to a real-life project, but that real-life project involved using jQuery with Rails, so I’m in the process of extracting the lessons learned on that project into something useful.

    I should have something simultaneous with jQuery 1.1 (mid-Jan.)

    Email me if you have additional questions. At worst, I should be able to help you get started with using jQuery with Rails.

    Comment by Yehuda Katz — 01.01.2007 @ 12.20.54 (556)

  2. That’s excellent news, I’m really looking forward to joR!

    Comment by Sohum — 01.01.2007 @ 12.52.15 (577)

  3. If you have any more questions you can IM me at outlookeic on AIM.

    Comment by Yehuda Katz — 01.01.2007 @ 15.34.56 (690)

  4. So this is a very good news, i fall in love with jquery 6month ago , and hope for integration with rail.
    thanx a lot katz

    Comment by Sisyphe — 08.01.2007 @ 01.12.44 (092)

  5. I figured out how to cleanly integrate jQuery Ajax with RESTful Rails controllers — including a way to deliver jQuery-formatted Javascript via RJS — see writeup here:

    http://mad.ly/2007/05/17/jquery-ajax-rails/

    Comment by Geoff Buesing — 21.05.2007 @ 05.10.36 (257)

  6. I just completed a plugin called jRails that makes using jQuery with Rails very easy. It is essentially a drop-in jQuery replacement for Prototype/script.aculo.us on Rails and you get all of the same default Rails helpers using the lighter jQuery library.
    http://www.ennerchi.com/projects/jrails

    Comment by Aaron — 27.11.2007 @ 08.37.21 (400)

  7. Hi….what i wanted to know was which is better….using jRails or jq4r by another guy or wait for jor by katz or use Geoff method to make jquery and prototype work side by side…for now i have just included th jquery library and made sure they dont conflict with prototype…but still would like to use its power with rails..so needs some guidance here….u can mail me at my email…thanks in advance

    Comment by Arjun — 21.12.2007 @ 20.46.37 (907)

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.