0

i am trying to fix a bit of broken code here. basically its a little data table that shows the person a bit of summary data so that they can get a overview about what they are seeing it is a hidden by a tag that changes from show demographics to hide demographics. i am using javascript to toggle these elements using a link_to_function to accomplish it.

here is the code i have:

def drawer_links(drawer_name)
  s = []
  js = "$('#target_table','#show_target_link','#hide_target_link').toggle()"
  s << link_to_function('Show ' + drawer_name, js, :id => 'show_target_link')
  s << link_to_function('Hide ' + drawer_name, js, :id => 'hide_target_link', :style => 'display:none')
  return s
end

here is the basic idea that i had thats when the show_target_link is clicked then it will hide itself and then show the hide_target_link and the target_table. and when you click on the hide_target_link it will hide itself and the target_table and show the show_target_link. the issue i am finding is that when i click on the link nothing happens nothing changes. if i change the code to

  js = "$('#target_table').toggle()"

then when i click on the link it will toggle the target_table and obviously the links dont change. how can i then select multiple elements to take that same action. there are no console errors. and by me clicking on the link dosent even trigger the log. so there is no way for me to kinda sniff this out. anyone whith ideas?

1 Answer 1

2

Try this, js = "$('#target_table,#show_target_link,#hide_target_link').toggle()"
if it's working or add a common class like toggleLink and and toggle link by toggleclass

Sign up to request clarification or add additional context in comments.

1 Comment

Amar your the man! like i bestow apon you 1 million points. and the title of awesome man.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.