putting <%=yield %> in a partial for ajax jquery calls

Posted by odpogn on Stack Overflow See other posts from Stack Overflow or by odpogn
Published on 2011-01-01T03:20:11Z Indexed on 2011/01/01 11:53 UTC
Read the original article Hit count: 277

Filed under:
|
|
|
|

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")) %>");

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails