Topic: Is RJS the right way?

Hi There,

because I wanna do some cool dynamic stuff I need to use JavaScript in my Application.

Some search brought me to RJS - which seems to be something like a JS -> Rails bridge (am I right?)

My Problem is, that there aren't any new Informations on the Web. Most of them are totaly outdated.
So is RJS actually in use? Or should I think about using JQuery or somethin else directly?

Thanks allot

Re: Is RJS the right way?

I believe rjs is mainly for rails 2.x.x, either way, I'd recommend using jQuery. It's constantly being developed and implemented and there is a lot of support for it. It's extremely popular and very powerful for developing rich interfaces.

- Ben

Re: Is RJS the right way?

Don't use rjs, prefer js files (jQuery is the best framework to write js imo) well tested, well documented and built using best practices.

At time you got a bit of complexity in your views (like states), it's a nightmare with rjs.

Re: Is RJS the right way?

Thanks allot.

Will give jQuery a try.

Shall I use this:

Re: Is RJS the right way?

The previous posters are RIGHT on! I started with RJS (with RoR 2.X because RoR defaulted to use it) maybe 1 year ago and I was hesitant to transition to jQuery because I  was afraid of the amount of rework it might create. I started making the transition a couple days ago and I am THRILLED working with jQuery. I wish I would have skipped RJS altogether. Not only is it easy to use, fast and powerful but I really like that it eliminates/removes JS from your views.

I think installing a jQuery plugins to get started is a bit much ... just include it via a CDN (claimed to be faster) in your default layout.

<%= javascript_include_tag '' %>

Last edited by jmesserer (2011-02-12 12:04:07)

Re: Is RJS the right way?

I'm not following this, it seems to me the posters are saying somehow RJS and JQuery are mutually exclusive?

RJS is really just another notational convenience useful for when you have a lot of dom twiddling to do.  It's a crude easy to use server side JavaScript generator that twiddles with your DOM.   It has sort of a training wheels vibe to it,  but if you don't want to mess with javaScript, it's handy.

JQuery is a client side JavaScript library.  I don't see how one precludes/excludes the use of the other?

I think it's fair to say if your proficient with JQuery, then RJS becomes less useful,  That said, I really don't use RJS much,  When constructing DOM manipulations with JQuery I use Builder::XmlBuilder mostly,  I have  lots's of code like this:

    xm =
    xm.div() {
      xm << "&nbsp;App ready, "
        :onclick=>"$(this).parent().parent().hide();" + 
      ) {
        xm << "click"
      xm << " to download"

Last edited by BradHodges (2011-02-12 18:58:43)

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Is RJS the right way?

My point was I don't even think RJS is still put to use in rails 3 though? At least I haven't seen it. Since I work with jQuery every day now I just write all my own jQuery, and I do it in my application.js, as to follow unobtrusive javascript practice, unlike this brad guy using onclick events :0 !

Last edited by RailsRhino (2011-02-13 16:51:52)

- Ben