Rails AJAX helpers or DIY


#1

I’ve used 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 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!


#2

Kris@AFM wrote:

I’ve used 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 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?


#3

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.
:slight_smile: