Forum: Ruby on Rails link_to_remote : render a view

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
803ad415efcdcbf09b1addeb319650d7?d=identicon&s=25 Adam Akhtar (thegeezer3)
on 2009-03-03 13:29
when a user clicks on a link_to_remote I would like to it to render a
view that i already have established. I know about page.redirect_to but
that would force a refresh. Id like to do something like page.replace
"an_existing_view"
is this possible or would i have to convert the view into a partial
first?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-03 14:03
(Received via mailing list)
On 3 Mar 2009, at 12:29, Adam Akhtar wrote:

>
> when a user clicks on a link_to_remote I would like to it to render a
> view that i already have established. I know about page.redirect_to
> but
> that would force a refresh. Id like to do something like page.replace
> "an_existing_view"
> is this possible or would i have to convert the view into a partial
> first?

You can replace any element on the page (so I suppose you could do an
update on the body element, although I've never done that.
It is most common to have a partial for exactly that bit of the page
that needs refreshing (if you're using ajax to refresh the entire page
then it seems to me like you might as well keep it simple and just do
a non ajax update) but you shouldn't have to do that.

Fred
803ad415efcdcbf09b1addeb319650d7?d=identicon&s=25 Adam Akhtar (thegeezer3)
on 2009-03-03 14:26
thanks fred, what im doing is pertty much like gmail. I have links on my
side nav equivalent to gmails "inbox" and "starred". When i click on
inbox in gmail it renders the list of emails in my inbox without a
refresh. Teh same with all "starred" etc. Id like that functionality.

So i guess id have to extract that area of the screen into a partial and
call it via a page.replace_html "the_partial" and for standard html
responses just render the same partial in the actions view? right???
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-03 14:51
(Received via mailing list)
On 3 Mar 2009, at 13:26, Adam Akhtar wrote:

> responses just render the same partial in the actions view? right???
Yes. If you're just updating that one page element you don't even need
replace_html, just do

link_to_remote 'blah', :update => 'some_id', ...

and have the corresponding controller render some (html) partial in
the normal way, the results of the render will be used to update the
page element with that id

Fred
This topic is locked and can not be replied to.