Topic: appending values to link href?

link_to_function("test", nil, :id => 'test_link') do |page|
  page.select('a.my_target_link_class').each  do |link|
    link.href = "/?test=test" # this works, but overwrites the href. I want to append to the href
  end
end


link_to_function("test", nil, :id => 'test_link') do |page|
  page.select('a.my_target_link_class').each  do |link|
    link.href = "#{link.href}/?test=test" # this throws an error: TYpeError: value.href is not a function
  end
end

Re: appending values to link href?

for your second example:
the link.href youi put in #7} is the problem. i think what have to do here is pass javascript:

link.href = "element.href+'?test=test'"

Note how i used "element" instead of link, which would be the real block variable. I have read somewhere that the RJS .each function has a few problems as you can specify any name for the blockvar, but when using it as the Javascript equivalent as we do here, it has to always be "element" (or "value" or something, i'm not entirely sure sad)

Re: appending values to link href?

Hi,
Thanks for your help
I tried that, but it just makes the href "element.href+'?test=test'" and does not append to the origional href