I would like to use the link_to_remote method in my controller so I can update a list within my .rhtml file without having to re-load the entire page. Basically, what I am doing is adding stuff to a list and then allowing that stuff to be deleted from the list if the user so chooses - all with the built-in AJAX functionality. The idea is that I do not want the entire page to re-load. I''m thinking that there is an eval() method that I can use but have not yet discovered it. Anyone have any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
try something like render_to_string :inline => "<%= link_to_remote ... %>" -fouad On Jun 27, 1:01 am, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I would like to use the link_to_remote method in my controller so I can > update a list within my .rhtml file without having to re-load the entire > page. Basically, what I am doing is adding stuff to a list and then > allowing that stuff to be deleted from the list if the user so chooses - > all with the built-in AJAX functionality. The idea is that I do not want > the entire page to re-load. I''m thinking that there is an eval() method > that I can use but have not yet discovered it. Anyone have any ideas? > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Shandy Nantz wrote:> I would like to use the link_to_remote method in my controller so I can > update a list within my .rhtml file without having to re-load the entire > page. Basically, what I am doing is adding stuff to a list and then > allowing that stuff to be deleted from the list if the user so chooses - > all with the built-in AJAX functionality. The idea is that I do not want > the entire page to re-load. I''m thinking that there is an eval() method > that I can use but have not yet discovered it. Anyone have any ideas?Put the snip of rHTML that needs to refresh into a partial. Include it the normal way, like this: <div id=''refresh_me''> <%= render :partial => ''my_partial'' %> </div> Now wire link_to_remote up to an action that looks like this: def my_action return unless request.xhr? render :update do |page| # <-- I call that rjs sometimes! page.replace_html ''refresh_me'', :partial => ''my_partial'' end end The deal is that almost* anything you can pass to render, you can also pass to the second argument to JavaScriptGenerator#replace_html. The first code injects raw HTML into your page as it renders, before it goes over the wire. The second snip renders the partial, then creates JavaScript containing Element.update(''refresh_me'', ''<my partial html codes>''). This goes over the wire, and the Ajax handlers from prototype.js will replace the innerHTML member of that <div id=''refresh_me''> with the new version. (Question for the lifers - is it _really_ "almost anything"? Or is it "anything"!?) -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I tried your idea and it seems to run (or at least it does not complain at all about any of the code), but when I attempt to delete the entry that I just added, nothing happens. -- 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 -~----------~----~----~----~------~----~------~--~---