confusion using rjs for a link_to_remote
Posted
by
odpogn
on Stack Overflow
See other posts from Stack Overflow
or by odpogn
Published on 2011-01-01T00:06:48Z
Indexed on
2011/01/01
0:54 UTC
Read the original article
Hit count: 162
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'
© Stack Overflow or respective owner