# Rails AJAX helpers or DIY

**URL:** <https://www.ruby-forum.com/t/rails-ajax-helpers-or-diy/95413>\
**Category:** Rails\
**Created:** [May 31, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/rails-ajax-helpers-or-diy/95413 "2006-05-31T16:49:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KrisSAFM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4af34b/32.png) [@KrisSAFM](https://www.ruby-forum.com/u/KrisSAFM)\
**Post date:** [May 31, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/rails-ajax-helpers-or-diy/95413/1 "2006-05-31T16:49:26Z")

</div>

I’ve used [script.aculo.us](http://script.aculo.us) before (pre-Rails) to do JS effects like  
having a menu link that when clicked shows a sub menu, that kind of  
thing.

Now I want to do something very similar but in Rails. Basically I have a  
list of summaries displayed in a view. I want to have a link that when  
pressed shows the detail.

To do this I would normally have each summary in a DIV, the ID of each  
DIV would have a number suffix. The on\_click event would pass the suffix  
to a JS function which would hide/show (using a [script.aculo.us](http://script.aculo.us) effect)  
the relevent DIV containing the detail.

How should I go about this in Rails, in other words is there a helper,  
better way of doing it, Javascript views maybe…

Best wishes!

---

<div class="post-metadata">

**Author:** ![KrisSAFM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4af34b/32.png) [@KrisSAFM](https://www.ruby-forum.com/u/KrisSAFM)\
**Post date:** [June 28, 2006, 12:38pm UTC](https://www.ruby-forum.com/t/rails-ajax-helpers-or-diy/95413/2 "2006-06-28T12:38:14Z")

</div>

Kris@AFM wrote:

> I’ve used [script.aculo.us](http://script.aculo.us) before (pre-Rails) to do JS effects like  
> having a menu link that when clicked shows a sub menu, that kind of  
> thing.
> 
> Now I want to do something very similar but in Rails. Basically I have a  
> list of summaries displayed in a view. I want to have a link that when  
> pressed shows the detail.
> 
> To do this I would normally have each summary in a DIV, the ID of each  
> DIV would have a number suffix. The on\_click event would pass the suffix  
> to a JS function which would hide/show (using a [script.aculo.us](http://script.aculo.us) effect)  
> the relevent DIV containing the detail.
> 
> How should I go about this in Rails, in other words is there a helper,  
> better way of doing it, Javascript views maybe…
> 
> Best wishes!

Any thoughts?

---

<div class="post-metadata">

**Author:** ![KrisSAFM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4af34b/32.png) [@KrisSAFM](https://www.ruby-forum.com/u/KrisSAFM)\
**Post date:** [June 28, 2006, 3:49pm UTC](https://www.ruby-forum.com/t/rails-ajax-helpers-or-diy/95413/3 "2006-06-28T15:49:46Z")

</div>

I would say it depends on your goal. There are lots of approaches to  
take in  
Rails. There are lots of helpers and even a great book on Rails and RJS  
from  
O’Reilly that you could investigate.

But if you have a timetable, just do it the way you know how and then  
refactor it later.

I still tend to use a bit of HTML form tags instead of the helper tags.  
🙂
