Hi, So I have a controller action that populated an instance variable @links. The Links are rendered as partials and displayed down the page in a div. What I want to do is: on clicking a link (from a dropdown menu) go to that same action, repopulate @links and replace the content in the page div with the new content. Is this a link_to_remote with an :update option, an rjs template with replace_html or something else? Thanks for you help. JB --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This would be a select which has an observer on it. Julian On 31/03/2008, at 9:00 AM, Jables wrote:> > Hi, > So I have a controller action that populated an instance variable > @links. The Links are rendered as partials and displayed down the > page in a div. What I want to do is: on clicking a link (from a > dropdown menu) go to that same action, repopulate @links and replace > the content in the page div with the new content. Is this a > link_to_remote with an :update option, an rjs template with > replace_html or something else? Thanks for you help. > > JB > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you look at rjs, you can do a page.replace_html div,
render :partial => ''partial''
You can call this from a link_to_remote, have the controller
repopulate the @links and let rjs do the trick.
You could also do it in the controller to replace the html like so:
if request.xhr?
render :update do |page|
page.replace_html div, :partial => ''partial''
end
end
Serge
On Mar 30, 7:00 pm, Jables
<brun3...-Meo6Lv8EUjg3uPMLIKxrzw@public.gmane.org>
wrote:> Hi,
> So I have a controller action that populated an instance variable
> @links. The Links are rendered as partials and displayed down the
> page in a div. What I want to do is: on clicking a link (from a
> dropdown menu) go to that same action, repopulate @links and replace
> the content in the page div with the new content. Is this a
> link_to_remote with an :update option, an rjs template with
> replace_html or something else? Thanks for you help.
>
> JB
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---