I have a faq where the answers are blinded down when the question is
clicked.
What I want to do is have a link that either blinds up or down all
the answer-elements on the page. When the link is clicked, it should
switch between the text "Show all" / "Hide all" and the
link_to_remote should also change. I figure I´ve made a mess out of it
as it is. Can I somehow make all this in action or something also?
How should I do this?
# in my controller:
def display_all
render(:update) do |page|
page.select(''div.answer'').each do |answer|
answer.visual_effect(:blind_down, :duration => 0.25, :fps =>
100)
end
page.replace_html :toggle_all, link_to_remote("Hide all",
{:url => {:action => :hide_all}}, :id => "toggle_all")
end
end
def hide_all
render(:update) do |page|
page.select(''div.answer'').each do |answer|
answer.visual_effect(:blind_up, :duration => 0.25, :fps =>
100)
end
page.replace_html :toggle_all, link_to_remote("Show all",
{:url => {:action => :display_all}}, :id => "toggle_all")
end
end
## in my template:
<%= link_to_remote("Show all",
{:url => {:action => :display_all}}, :id
=> "toggle_all")%>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---