# Is RJS highly used by Rails developers? (learning RJS versus just going to jQuery or Protype)

**URL:** <https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756>\
**Category:** Rails\
**Created:** [February 19, 2009, 12:31pm UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756 "2009-02-19T12:31:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 19, 2009, 12:31pm UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/1 "2009-02-19T12:31:47Z")

</div>

Hi,  
Question - If I’m starting to use Rails javascript/ajax helpers but want  
to  
start doing some more custom/complex Ajax/Javascript should I learn RJS  
as  
part of moving forward? (or alternatively just look to either diving  
into  
jQuery or Prototype/Scriptaculous?)

Tks

–  
Greg  
[http://blog.gregnet.org/](http://blog.gregnet.org/)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 19, 2009, 1:00pm UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/2 "2009-02-19T13:00:04Z")

</div>

I think that if you will be doing complex javascript stuff then you  
should dig into jQuery (or another js library) since you have to know  
your tool very well.

Rails’s javascript helpers are useful but they shield you from having  
to know the javascript part. That can be an advantage when you need  
something really fast but on the long-term you’d be better off writing  
javascript yourself. Plus, the helpers “pollute” the html markup with  
javascript code which is not very nice.

Balint

On Feb 19, 12:30 pm, Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 19, 2009, 1:28pm UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/3 "2009-02-19T13:28:10Z")

</div>

Greg H. wrote:

> Hi,  
> Question - If I’m starting to use Rails javascript/ajax helpers but want  
> to  
> start doing some more custom/complex Ajax/Javascript should I learn RJS  
> as  
> part of moving forward? (or alternatively just look to either diving  
> into  
> jQuery or Prototype/Scriptaculous?)

We use Prototype for its amazing simplicity in sortable lists, and  
jQuery for some other stuff not covered by Prototype like embedding  
Flowplayer in our pages.

–  
Training videos for distance learners: [http://www.digiprof.fr](http://www.digiprof.fr)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 20, 2009, 12:25am UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/4 "2009-02-20T00:25:18Z")

</div>

When my AJAX application got complex, I decided it was best to  
separate the HTML view from the Ruby controller code as much as  
possible. All AJAX calls were modified to respond with JSON data, and  
the page updates were coded in static javascript functions. I haven’t  
used jQuery, we used ExtJS to great effect. You’ll want to use  
something, otherwise you will have to deal with cross-browser  
compatibility yourself.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 20, 2009, 12:30am UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/5 "2009-02-20T00:30:00Z")

</div>

2009/2/20 kevin cline [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> You’ll want to use something, otherwise you will have to deal with  
> cross-browser  
> compatibility yourself.

Kevin - can I ask what you meant by this exactly? didn’t quite  
understand  
this last line of yours. Also running with your approach does this mean  
you  
drop use of the Rails helpers (e.g. remote\_form\_for, etc)?

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 20, 2009, 1:29am UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/6 "2009-02-20T01:29:42Z")

</div>

Since you’re on the subject of jQuery, would you mind helping me with  
something? I am trying to add new file\_fields using a link so I can  
add more Asset objects to my Project. I know how to generate files,  
and tried it substituting the id numbers with a variable that  
increased, etc. But then I realized I wasn’t creating actual objects  
so these new fields wouldn’t save!

So now I am sort of stuck. Here is what I am working with (new view,  
and partial). How can I get that partial to generate using jQuery?

[http://pastie.org/private/gqhqxwzsh220zzhwhbvw](http://pastie.org/private/gqhqxwzsh220zzhwhbvw)

On Feb 19, 11:47 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 19, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/is-rjs-highly-used-by-rails-developers-learning-rjs-versus-just-going-to-jquery-or-protype/160756/7 "2009-02-19T17:48:47Z")

</div>

On 19 Feb 2009, at 11:30, Greg H. wrote:

> Hi,
> 
> Question - If I’m starting to use Rails javascript/ajax helpers but  
> want to start doing some more custom/complex Ajax/Javascript should  
> I learn RJS as part of moving forward? (or alternatively just look  
> to either diving into jQuery or Prototype/Scriptaculous?)

Personally I feel that rjs can be a bit of a crutch as there is only  
so much it can do (or some things that it doesn’t do as well as using  
raw js).  
I found The prototype & scriptaculous book (Christophe P.)  
very useful, mainly because it showed me that javascript doesn’t have  
to be horrible. It sort of depends what you’re going to be doing  
really - you can probably carrying with rjs if you’re just using the  
odd scriptaculous effect or ajax request, but you usually can do those  
things in a cleaner way with a bit more knowledge of JS. In my case we  
have quite a lot of javascript which would have been hellish (and hard  
to test) with rjs (we have a variety of javascript classes which  
encapsulate the behaviour of a particular ‘widget’ on the screen)

Fred
