Forum: Ruby on Rails RJS collection proxy

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-01-31 11:40
I would like to update the class of all <a> tags found in a div of my
page..
I can get it all (seeing the index and value) using :

page.select("#header_domain_map a").each do |value, index|
  page << 'alert(value);'
end

but how can I set the classof all these elements to class="active"

tfyl

kad
675475d0b65710be6d992eb5eb2c61c2?d=identicon&s=25 Gregory Seidman (Guest)
on 2007-01-31 18:53
(Received via mailing list)
On Wed, Jan 31, 2007 at 11:40:06AM +0100, Kad Kerforn wrote:
> I would like to update the class of all <a> tags found in a div of my
> page..
> I can get it all (seeing the index and value) using :
>
> page.select("#header_domain_map a").each do |value, index|
>   page << 'alert(value);'
> end
>
> but how can I set the classof all these elements to class="active"

Just because RJS can be used to generate JavaScript doesn't mean it's
the
easiest way to accomplish things in JavaScript. I assume that you are
using
Prototype since you are using RJS at all, so:

page << '$$("#header_domain_map a").each(function(a) { a.className =
"active"; });'

> tfyl
> kad
--Greg
This topic is locked and can not be replied to.