I am playing with the new .rjs stuff in edge rails.
I am doing stuff like :
page.replace_html ''scoops_tot'', @scoops.size
1. I want to add my own javascript functions to the page object.
Is it possible and how ?
2. I am trying to update several fields, but i would like a to have a
dekay between the updates :
@anoclicks.each{|aclick|
page.replace_html ''click_number_''+aclick.scoop.id.to_s ,
aclick.scoop.clicks_tot.to_i + aclick.scoop.anoclicks_tot.to_i
page.visual_effect :Pulsate, "click_me_#{aclick.scoop.id}"
}
--
Posted via http://www.ruby-forum.com/.
Hi, On 8 Feb 2006, at 12:43, jm goom wrote: I haven''t used rjs yet, but I have got the "Rails Recipes" beta book (well worth buying BTW).> 1. I want to add my own javascript functions to the page object. > Is it possible and how ?Reading through the file*, I see this method which may be what you want: # Writes raw JavaScript to the page. def <<(javascript) @lines << javascript end> 2. I am trying to update several fields, but i would like a to have a > dekay between the updates :You want something like this (from the book): page.delay(3) do page.alert @rails_version end which I''m sure you can adapt for your purposes. Jon * actionpack/lib/action_view/helpers/prototype_helper.rb
Thank you for your answer I have the book in front of me (the pdf of course) I did not see this << method, but just found it in the last version of the doc ! Great ! For the delay, i cannot get it working more than once. I want to execute an effect for each item in an array and each time apply the same delay... I am going to play with that << thing. Thanks a lot :) -- Posted via http://www.ruby-forum.com/.
jm goom wrote:> Thank you for your answer > I have the book in front of me (the pdf of course) > I did not see this << method, but just found it in the last version of > the doc ! Great ! > > For the delay, i cannot get it working more than once. > I want to execute an effect for each item in an array and each time > apply the same delay... I am going to play with that << thing. > > Thanks a lot :)I haven''t tried it, but it may be possible to nest delay blocks. page.delay(3) do page.do_something page.delay(3) do page.do_something_again end end _Kevin -- Posted via http://www.ruby-forum.com/.
I found a solution that is working great :
i = 0
@hp.each{ |hp|
page.delay(i) do
page.visual_effect :Fade, ''scoop_''+hp.id.to_s
i+=1
end
}
Thx for your help
--
Posted via http://www.ruby-forum.com/.
On 2/8/06, jm goom <jm@scoopeo.com> wrote:> I found a solution that is working great : > > i = 0 > @hp.each{ |hp| > page.delay(i) do > page.visual_effect :Fade, ''scoop_''+hp.id.to_s > i+=1 > end > }More ruby-like: @hp.each_with_index do |hp, index| page.delay(index) do page.visual_effect :Fade, "scoop_#{ hp.id }" end end