Forum: Ruby on Rails Can you apply effects to elements create in same RJS file?

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.
E73e46e7c2e61b1bd499a627224d6eaa?d=identicon&s=25 Nigel Thorne (nigelthorne)
on 2006-05-08 12:08
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
631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-05-08 12:34
(Received via mailing list)
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.
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-05-08 12:39
Nigel Thorne 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
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-05-08 17:53
(Received via mailing list)
On Monday, May 08, 2006, at 12:08 PM, Nigel Thorne 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
>Rails@lists.rubyonrails.org
>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
This topic is locked and can not be replied to.