What is the best way to create a hide and show effect in rails 2. Is it to use a JQuery type solution or is there something as good, better or easier built in?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to use link_to_function in the view:
Another way to do it is to use RJS, but it depends a lot on how your application. That way you’d have to set up your controller to look for either custom actions outside of the RESTful actions, or have the exisiting actions look for XHR requests (using “if request.xhr?”)
The RJS is pretty easy:
Personally, I’d say that anything more than $(element).toggle() deserves to be outside the view into it’s own RJS, since the view is supposed to be mostly free of logic, but probably there’s a lot of differing opinions on that.
As for the javascript framework, unless I am doing something really that requires something that isn’t available in prototype/scriptaculous, I’ll just stick with the defaults for simplicity.