Hello, I want to update more than 1 div inside the page with 1 AJAX call. I noticed you can only render 1 at a time in Rails methods and also you can only set 1 update: inside form_remote_for. What is the best way to update more than once? I was thinking to deliver it back in hidden field and then use JavaScript to upload it in the other DIV. I''m guessing though there must be better way to do this in rails Any ideas? Thanks, Tam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2009-Apr-01 05:23 UTC
Re: What is the best way to update more that 1 div in AJAX call
> > I want to update more than 1 div inside the page with 1 AJAX call. > I noticed you can only render 1 at a time in Rails methods and also > you > can only set 1 update: inside form_remote_for. > > What is the best way to update more than once?Look into update_page and the methods you can put inside it''s block (particular replace_html). In the form_remote_for/link_to_remote case you don''t specify the :update parameter. Let the RJS that gets returned do your bidding. You''re still only rendering one thing, but that render is a bunch of JS that does what you want... update_page(&block) Yields a JavaScriptGenerator and returns the generated JavaScript code. Use this to update multiple elements on a page in an Ajax response. See JavaScriptGenerator for more information. Example: update_page do |page| page.hide ''spinner'' # and other things.... end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sijo Kg
2009-Apr-01 05:49 UTC
Re: What is the best way to update more that 1 div in AJAX c
Hi In controller suppose action is replace_this then create a file replace_this.rjs in the same folder Now in action write render :action => ''replace_this.rjs" And open replace_this.rjs page[:div1].replace_html :partial=>"partial_here"} Above you can use :inline, etc instead of :partial Look http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tam Kbe
2009-Apr-01 06:20 UTC
Re: What is the best way to update more that 1 div in AJAX call
Thanks a lot Philip and Sijo, you solutions are very helpful I will be using RJS for that -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---