Can you apply effects to elements create in same RJS file?

I am trying to create a new element in a list and highlight it.
I am doing the following in my rjs file:

page.insert_html :after, ‘bananalist_header’, :partial => ‘banana’
page.visual_effect :highlight, “banana#{banana.id}”, :duration => 1

The first line creates a new element with the id= ‘banana3’ say…
The second line then tries to highlight the new element.

This script fails as the second element doesn’t exist before the script
starts running. Is there some way to make this work? If I change the
second line to reference an existing element ‘banana1’ say, then it
highlights it fine.

Any suggestions?

Cheers
Nigel

It works for me, I do that quite often. You’re probably not
highlighting the right id, or maybe you’ve got the same id in your
document twice.

-Jonathan.

Nigel T. wrote:

I am trying to create a new element in a list and highlight it.
I am doing the following in my rjs file:

page.insert_html :after, ‘bananalist_header’, :partial => ‘banana’
page.visual_effect :highlight, “banana#{banana.id}”, :duration => 1

Could it be that it’s supposed to be #{@banana.id} ? (I don’t know,
just guessing).

Alan

On Monday, May 08, 2006, at 12:08 PM, Nigel T. wrote:

starts running. Is there some way to make this work? If I change the
Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

All the lines in the RJS file fire simultaneously.

If you wrap the second line in a delay(0.1), it should work fine and
really not be noticable.

_Kevin