Nigel Thorne
2006-May-08 10:08 UTC
[Rails] 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 -- Posted via http://www.ruby-forum.com/.
Jonathan Viney
2006-May-08 10:30 UTC
[Rails] Can you apply effects to elements create in same RJS file?
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. On 5/8/06, Nigel Thorne <rubyforum@nigelthorne.com> 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 > > 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 > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Alan Francis
2006-May-08 10:39 UTC
[Rails] Re: Can you apply effects to elements create in same RJS fil
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 => 1Could it be that it''s supposed to be #{@banana.id} ? (I don''t know, just guessing). Alan -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-May-08 15:50 UTC
[Rails] Can you apply effects to elements create in same RJS file?
On Monday, May 08, 2006, at 12:08 PM, 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 > >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 > > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsAll 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 -- Posted with http://DevLists.com. Sign up and save your mailbox.