putting <%=yield %> in a partial for ajax jquery calls
- by odpogn
I'm trying to make the "home" link in my <%= render 'layouts/header' %> do an ajax/jquery call to change the <%= yield %> in a partial inside my content div. all i get are blanks in the view.. <%= yield %> works fine when put in a partial without ajax, but it doesn't display anything when using ajax... can yield not be used this way?
all I'm really looking for is the ability to click on my sites navigation links without having to reload the entire page...
my application.html.erb file looks like so:
<head>
$(function() {
$("#home").live("click", function() {
$.get(this.href, null, null, "script");
return false; }); });
</head>
<body>
<div id="container">
<%= render 'layouts/header' %>
<div id="content">
<%= render 'layouts/content' %>
</div>
<%= render 'layouts/footer' %>
</div>
</body>
my <%= render 'layouts/header' %> contains:
<%= link_to "Home", root_path, :id => "home" %>
my <%= render 'layouts/content' %> only contains:
<%= yield %>
home.js.erb
$("#content").html("<%= escape_javascript(render("layouts/content")) %>");