views:

125

answers:

2

I have a div that I want to show or hide depending on whether a hyperlink is clicked. This obviously doesn't require any server-side interaction. But is there a way to do this using Rails' prototype helpers? Or should I simply use JQuery or pure Javascript to do this type of client-side manipulation?

+2  A: 

You should absolutely be using jQuery. The best reason is because of how little code it is:

$("a.myLink").click(function() { $("#myDiv").toggle() });
Yehuda Katz
Thanks. Wasn't sure if this went against the Rails way of doing things.
ipso facto
Not at all :) Virtually all serious Rails applications use custom JavaScript. The built-in helpers are just there to get you going quickly at first.
Yehuda Katz
+1  A: 
John Topley
Thanks. Slightly more verbose. But not as much as I expected from all the talk about how concise jquery is.
ipso facto
yeah... it's not a huge difference on trivial things, because Prototype in recent iterations has made the trivial syntax quite close to jQuery's. It adds up over larger applications though.
Yehuda Katz