Thanks for your thoughts. It got me on the right path. I ended up
with a solution that had a small amount of frontend javascript code to
manage the ajax calls. I used remote_function to create functions out
of the ajax call and put them in an array so I could call them
whenever I wanted. It looked something like this.
on th page:
var calls_to_be_made = [];
in the view:
<% subtasks.each do |subtask| %>
<div id="<%= dom_id(subtask) %>">
... content here
</div>
calls_to_be_made[calls_to_be_made.length] = function(){ <%=
remote_function(:update => dom_id(subtask), etc...) };
<% end %>
With this method I was able to start as many subtasks as I wanted like
this:
calls_to_be_made[0]();
calls_to_be_made[1]();
and then when one call returned I could have it kick of the next one
until there are none left.
Thanks!
Jonathan
On Dec 26, 4:16 pm, Frederick Cheung <[email protected]>
wrote:
> On 26 Dec 2008, at 21:56, JHuizingh wrote:
>
>
>
> > Is there a way that I can use the AJAX functionality built into rails
> > to make this happen without having to do some sort of custom control
> > mechanism to track all of the SubTasks on the client side? Or is
> > there a better strategy to go about this?
>
> if the ajax update just re-rendered the list of subtasks then that
> would probably be enough.
> Or if you want to use something fancier then you might have something
> like
>
> def progress
> #find the subtask that completed and assign it to @subtask
> render :update do |page|
> page[dom_id(@subtask)].addClassName('complete')
> end
> end
>
> which will add the complete class to the div/span/whatever with the
> appropriate id. You could then style it so that such items had a green
> background or a check mark or whatever visual cue you want to give.
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---