Rails AJAX question, calling remote_function in a loop

I think I may be missing something here. I have a collection of people
I want to run through. For each person I want to use AJAX to make a
calculation and update the page with the results. First I tried to do
this with just links, which works fine. It looks like this

<% @eligible_players.each do |player| %>

<%= link_to_remote( player.player_name, :update => "playerList" + player.id.to_s, :url =>{ :action => :calc_wins_losses_for_player, :id => player.id }, :position => "top", :complete => visual_effect(:highlight, "playerList" + player.id.to_s, :duration => 1) ) %> "> <% end %> So you have the list on the left, and when you click on a player's name it runs the calculation and updates the page correctly.

Now my question is this, how can I do this so that the user does not
have to click on the names in order to make that call. I was looking at
the JS reference in the rails API, and it seemed like remote_function is
the way to go. I tried the following

<% @eligible_players.each do |player| %>

<%= remote_function( :update => "playerList" + player.id.to_s, :url =>{ :action => :calc_wins_losses_for_player, :id => player.id }, :position => "top", :complete => visual_effect(:highlight, "playerList" + player.id.to_s, :duration => 1) ) %> "> <% end %>

but this did not work. Just as a test I tried the
periodically_call_remote, but that obviously does not really work
correctly in this case, because it can call the same thing more than
once per person.

What am I missing here?

Thanks in advance,

Actually I guess I am missing the point that client should not be
dictating when the processing is done necessarily. So outside of that,
is what I posted above possible?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs