I am playing with the new .rjs stuff in edge rails.
I am doing stuff like :
page.replace_html ‘scoops_tot’, @scoops.size
-
I want to add my own javascript functions to the page object.
Is it possible and how ?
-
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}”
}
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).
- 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
- 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
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
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 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
On 2/8/06, jm goom [email protected] 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