# Rails Ajax questions

**URL:** <https://www.ruby-forum.com/t/rails-ajax-questions/133364>\
**Category:** Rails\
**Created:** [March 31, 2008, 12:01am UTC](https://www.ruby-forum.com/t/rails-ajax-questions/133364 "2008-03-31T00:01:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [March 31, 2008, 12:01am UTC](https://www.ruby-forum.com/t/rails-ajax-questions/133364/1 "2008-03-31T00:01:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [March 31, 2008, 2:24am UTC](https://www.ruby-forum.com/t/rails-ajax-questions/133364/2 "2008-03-31T02:24:48Z")

</div>

This would be a select which has an observer on it.

Julian

---

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [March 31, 2008, 4:33pm UTC](https://www.ruby-forum.com/t/rails-ajax-questions/133364/3 "2008-03-31T16:33:40Z")

</div>

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
