Hi. I''m developing a Ruby Application. I would like to perform several actions, that is, call more than one action in 1 controller when someone clicks the submit_tag using ajax, rjs, etc. Right now it is working perfectly but with just one call. This is how the code looks like: <% form_remote_for :tag, :loading => visual_effect(:appear, :loading_div), :success => visual_effect(:fade, :loading_div), :failure => "alert(''HTTP Error '' + request.status + ''!'')", #visual_effect(:fade, :loading_div), :url => {:controller => "build", :action => "parse"} do | f| %> Search: <%= f.text_field :title %> <%= submit_tag "Submit" %> <% end %> So the idea is to have two :url => {:controller => "build", :action => "parse"} :url => {:controller => "build", :action => "parse2"} and when someone clicks the button to run both of them concurrently. Is this possible in any way? Thanks in advance ;) Happy 2008 ;) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Javier Quevedo wrote:> Hi. I''m developing a Ruby Application. I would like to perform several > actions, that is, call more than one action in 1 controller when > someone clicks the submit_tag using ajax, rjs, etc. > Right now it is working perfectly but with just one call. > This is how the code looks like: > <% form_remote_for :tag, > :loading => visual_effect(:appear, :loading_div), > :success => visual_effect(:fade, :loading_div), > :failure => "alert(''HTTP Error '' + request.status + > ''!'')", #visual_effect(:fade, :loading_div), > :url => {:controller => "build", :action => "parse"} do | > f| %> > > > Search: <%= f.text_field :title %> > > <%= submit_tag "Submit" %> > > <% end %> > > So the idea is to have two > :url => {:controller => "build", :action => "parse"} > :url => {:controller => "build", :action => "parse2"} > and when someone clicks the button to run both of them concurrently. > Is this possible in any way?Yes, add option :html => {:onsubmit => remote_function(:url => {:controller => ''build'', :action => :parse2})} -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
what if I want to have 3 or 4? or 100? Thanks for your reply! On Jan 1, 5:34 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> Javier Quevedo wrote: > > Hi. I''m developing a Ruby Application. I would like to perform several > > actions, that is, call more than one action in 1 controller when > > someone clicks the submit_tag using ajax, rjs, etc. > > Right now it is working perfectly but with just one call. > > This is how the code looks like: > > <% form_remote_for :tag, > > :loading => visual_effect(:appear, :loading_div), > > :success => visual_effect(:fade, :loading_div), > > :failure => "alert(''HTTP Error '' + request.status + > > ''!'')", #visual_effect(:fade, :loading_div), > > :url => {:controller => "build", :action => "parse"} do | > > f| %> > > > Search: <%= f.text_field :title %> > > > <%= submit_tag "Submit" %> > > > <% end %> > > > So the idea is to have two > > :url => {:controller => "build", :action => "parse"} > > :url => {:controller => "build", :action => "parse2"} > > and when someone clicks the button to run both of them concurrently. > > Is this possible in any way? > > Yes, add option > > :html => {:onsubmit => remote_function(:url => {:controller => ''build'', :action => :parse2})} > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Having multiple is just stupid. If you want it to do multiple things at the same time, stick them all in the same action and only call one URL. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Not really Ryan. There is at least one case in which is interesting to do. Since you can''t have more than one render per action and there are times when you want to render partials concurrently. So, is there any way to do it? I was trying another solution by creating Threads in the controller but i think that it will be easier this way. Check http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e11f83680ee71eef to see what happens if you try to do it with multiple threads and multiple renders. On Jan 1, 11:39 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Having multiple is just stupid. If you want it to do multiple things at the > same time, stick them all in the same action and only call one URL.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can render as many partials as you want, concurrently. For example: <%= render :partial => "number_1" %> <%= render :partial => "number_2" %> If you''re using render :update in your action do a page.replace_html :element_on_the_page, :partial => "number_1" page.replace_html :other_element_on_the_page, :partial => "number_2" --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Javier Quevedo wrote:> what if I want to have 3 or 4? or 100?You can create a JavaScript function that is called by the onsubmit event, and which calls remote_function in a loop. Concurrency will however be limited by both the number of simultaneous connections for a browser and the number of Rails handlers you are running. However this method does allow multiple changes to be sent to the browser concurrently, in contrast to the Thread option (in your other post), which only sends to the browser when all threads have completed. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---