I have been try to make a page where a user can add something to a list
and then delete something from the same list all without re-loading the
page. The adding part is easy, but the deleting part is turning out to
be a pain.
A user by the name of Philip gave me some very helpful hints:
Put the snip of rHTML that needs to refresh into a partial. Include it
normal way, like this:
Now wire link_to_remote up to an action that looks like this:
return unless request.xhr?
render :update do |page| # <-- I call that rjs sometimes!
page.replace_html ‘refresh_me’, :partial => ‘my_partial’
The deal is that almost* anything you can pass to render, you can also
The first code injects raw HTML into your page as it renders, before it
over the wire. The second snip renders the partial, then creates
containing Element.update(‘refresh_me’, ‘’). This
goes over the wire, and the Ajax handlers from prototype.js will replace
innerHTML member of that
(Question for the lifers - is it really “almost anything”? Or is it
“Test Driven Ajax (on Rails)”
This does not work, however, it just reloads the entire page within the
list. Does anyone have any other ideas or sugestions. I realize that I
am probably implementing the above code wrong, but I have tried every
way that I can think of. Thanks,