Tom Lianza
2006-Feb-09 16:07 UTC
[Rails] Strategies for updating multiple parts of the page with AJAX
Hi all, I have a layout that''s evolving, but it looks like there will be several divs. I''m trying to keep everything AJAX-y and avoid full page reloads. My problem is, if I have the login box in a div, I''m going to want two other divs to effectively "refresh" themselves to get data from the server now that there is a user logged in. I''m trying to figure out how to accomplish this. I know I can''t do this with my current layout, because each of these divs I want to refresh is currently just a partial page template included on a page - nothing AJAXy about them. If I want to have the ability to call on parts of the page to update themselves, any ideas how I can do that? I''m not sure if there are rails helpers I can use, or if I should start looking into hand-coding Javascript with the prototype library to come up with a way. Also, if my mental model of how to do page updates is wrong, please correct me. Thanks! Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060209/48e72d00/attachment.html
Kevin Olbrich
2006-Feb-09 16:34 UTC
[Rails] Re: Strategies for updating multiple parts of the page with
Tom Lianza wrote:> Hi all, > > I have a layout that''s evolving, but it looks like there will be several > divs. I''m trying to keep everything AJAX-y and avoid full page reloads. > My > problem is, if I have the login box in a div, I''m going to want two > other > divs to effectively "refresh" themselves to get data from the server now > that there is a user logged in.Sounds like you might like RJS templates. They are in edge rails but I think there is a plugin for rails 1.0. Alternatively, you could add some javascript to the :complete callback in link_to_remote that will fire off another request. link_to_remote ''link'', :update=>''testdiv'', :url=>{:action=>''action''}, :complete=> remote_function(:update=>''testdiv2'', :url=>{:action=>''action2''}) should do the trick. _Kevin -- Posted via http://www.ruby-forum.com/.
Roberto Saccon
2006-Feb-09 16:38 UTC
[Rails] Strategies for updating multiple parts of the page with AJAX
just take a look at RJS (at rails edge), this is the easiest way for multiple partial AJAX page reloads without handcoded javascript On 2/9/06, Tom Lianza <tlianza@gmail.com> wrote:> > Hi all, > > I have a layout that''s evolving, but it looks like there will be several > divs. I''m trying to keep everything AJAX-y and avoid full page reloads. My > problem is, if I have the login box in a div, I''m going to want two other > divs to effectively "refresh" themselves to get data from the server now > that there is a user logged in. > > I''m trying to figure out how to accomplish this. I know I can''t do this > with my current layout, because each of these divs I want to refresh is > currently just a partial page template included on a page - nothing AJAXy > about them. If I want to have the ability to call on parts of the page to > update themselves, any ideas how I can do that? I''m not sure if there are > rails helpers I can use, or if I should start looking into hand-coding > Javascript with the prototype library to come up with a way. > > Also, if my mental model of how to do page updates is wrong, please > correct me. > > Thanks! > Tom > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Roberto Saccon - http://rsaccon.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060209/830f50b2/attachment.html