confusion using rjs for a link_to_remote
- by odpogn
My application layout contains a navigation div, and a content div constructed as a partial. I want to use ajax so that whenever a person clicks on a link in the navigation div, the contents of that page renders in the content div without a refresh. I'm confused on how to properly do this... any help for a rails noob??? thanks in advance~
application.html.erb
<body>
<div id="container">
<%= render 'layouts/header' %>
<%= render 'layouts/content'%>
<%= render 'layouts/footer' %>
</div>
</body>
_header.html.erb
<%= link_to_remote "Home", :url => { :controller => "pages", :action => "home" } %>
_content.html.erb
<div id="content">
<%= yield %>
</div>
pages_controller.rb
def home
@title = "Home"
respond_to do |format|
format.js
end
end
home.rjs
page.replace_html :container, :partial => 'layouts/content'