# RJS suitable for doing interactivities within a webpage?

**URL:** <https://www.ruby-forum.com/t/rjs-suitable-for-doing-interactivities-within-a-webpage/189234>\
**Category:** Rails\
**Created:** [May 27, 2010, 7:48am UTC](https://www.ruby-forum.com/t/rjs-suitable-for-doing-interactivities-within-a-webpage/189234 "2010-05-27T07:48:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 27, 2010, 7:48am UTC](https://www.ruby-forum.com/t/rjs-suitable-for-doing-interactivities-within-a-webpage/189234/1 "2010-05-27T07:48:26Z")

</div>

RJS is very good for sending Javascript code back to the browser saying  
“Your AJAX is successful and by the way you can update the UI to signal  
to the user using the following Javascript I am going to send you.”

How about other webpage interactivities, dynamic HTML, is RJS suited for  
doing that as well, or is Prototype.js, or jQuery, or plain Javascript  
statically loaded with the webpage, still more suited for doing it?

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 27, 2010, 9:58am UTC](https://www.ruby-forum.com/t/rjs-suitable-for-doing-interactivities-within-a-webpage/189234/2 "2010-05-27T09:58:59Z")

</div>

On May 27, 6:48 am, Jian L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> RJS is very good for sending Javascript code back to the browser saying  
> “Your AJAX is successful and by the way you can update the UI to signal  
> to the user using the following Javascript I am going to send you.”
> 
> How about other webpage interactivities, dynamic HTML, is RJS suited for  
> doing that as well, or is Prototype.js, or jQuery, or plain Javascript  
> statically loaded with the webpage, still more suited for doing it?

Well stuff like link\_to\_function, button\_to\_function etc… do allow  
you to supply a block (which yields an RJS page object) rather than a  
javascript fragment and there’s also the update\_page helper which can  
turn a block of rjs into actual javascript. I’ve always thought of RJS  
as a bit of a crutch though. It doesn’t get too much in your way for  
simple stuff like toggle this field or highlight that object but  
beyond that it has its limitations. It’s awkward to test for example  
and fiddly to setup reusable classes or functions. If you need any  
substantial amount of javascript I really thing you should bite the  
bullet and just get comfortable with javascript (using a library like  
jquery or prototype is almost certainly a smart move though)

Fred
