# RJS: How to highlight multiple items

**URL:** <https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296>\
**Category:** Rails\
**Created:** [September 23, 2008, 11:14am UTC](https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296 "2008-09-23T11:14:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 23, 2008, 11:14am UTC](https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296/1 "2008-09-23T11:14:28Z")

</div>

I have an array with many DIV ids.  
I want to highlight all at once.  
The current…  
page.visual\_effect :highlight, “div\_id”  
only takes one div id.

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 23, 2008, 11:48am UTC](https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296/2 "2008-09-23T11:48:13Z")

</div>

On Tue, Sep 23, 2008 at 2:14 AM, Vapor …  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I have an array with many DIV ids.  
> I want to highlight all at once.  
> The current…  
> page.visual\_effect :highlight, “div\_id”  
> only takes one div id.

Hi, you should be able to do the following:

Using RJS:

page.array\_of\_divs.each do |div|  
page.visual\_effect :highlight, div  
end

or

page.array\_of\_divs.each do |div|  
page[div].visual\_effect :highlight  
end

Using Prototype Javascript Library:

array\_of\_divs.each( function( value ) {  
value.visualEffect( “highlight” );  
});

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 23, 2008, 7:56pm UTC](https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296/3 "2008-09-23T19:56:20Z")

</div>

> page.array\_of\_divs.each do |div|  
> page.visual\_effect :highlight, div  
> end

How do I pass an array from controller?  
I am using removed\_email\_address@domain.invalid  
but it doesn’t work  
some template compile error

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [September 23, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/rjs-how-to-highlight-multiple-items/149296/4 "2008-09-23T21:01:49Z")

</div>

On 23 Sep 2008, at 18:56, Vapor … wrote:

> > page.array\_of\_divs.each do |div|  
> > page.visual\_effect :highlight, div  
> > end
> 
> How do I pass an array from controller?  
> I am using removed\_email\_address@domain.invalid

@newitems.each do |item|  
…  
end

Fred
