<% @items.each do |item| %>
#this links to show.rhtml and renders the content it should
<%= link_to item.title, :action => "show", :id => item.id %>
<% end %>
<div class="content">
<%= render :partial => "show", :id => item.id %>
</div>
If you want to use the ajax method, you'll need to use link_to_remote
instead of simply link_to, then define an Ajax callback method in your
controller, and then call
render :update do |page|
page.replace.html 'my_div', 'my_partial_name'
end
search for link_to_remote on api.rubyonrails.org for more information
On Oct 29, 11:24 pm, "Mike Garey" <random...@gmail.com> wrote:
> you need to either use an ajax call to update the contents of the page
> with the partial, or you can render all the partials and then use
> javascript to toggle (show/hide) the container div. Ajax is probably
> the better solution, since you're loading content only when the user
> requests it, rather than the Javascript approach which requires you to
> load the information for every item at once.
>
> If you want to use the ajax method, you'll need to use link_to_remote
> instead of simply link_to, then define an Ajax callback method in your
> controller, and then call
>
> render :update do |page|
> page.replace.html 'my_div', 'my_partial_name'
> end
>
> search for link_to_remote on api.rubyonrails.org for more information
>