Topic: Update div

Hello,

I want to update the div "datos" without refreshing the full page(ajax).
I use Rails 3 and 'link_to' with the option remote=>true,  without the :remote =>
true the div is updated but the full page, and it does nothing.

Anybody can help me?
This is my code:


application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Example</title>
    <%= csrf_meta_tag %>
    <%= render 'layouts/stylesheets' %>
    <%= javascript_include_tag :defaults %>
  </head>

  <body>
    <div class="container">
        <%= render 'layouts/header' %>
        <div class ="datos" id="datos" >
            <%= yield %>
        </div>
    </div>
  </body>
</html>




_header.html.erb

<header>
    div class="menu">
        <% = link_to "Link", about_path,: remote => true%>
    </div>
</header>



routes.rb

SampleApp::Application.routes.draw do
  match '/about', :to => 'pages#about'
  root :to => 'pages#home'
end




Thank you.

Last edited by lopilopi (2010-12-02 11:07:33)

Re: Update div

if should look more like this:

_header.html.erb

<header>
    div class="menu">
        <% = link_to_remote "Link", about_path, :update=>'datos' %>
    </div>
</header>

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Update div

If I use this command get an error: "undefined method `link_to_remote' "
I'm using Rails 3.

Thanks.

Re: Update div

'link_to_remote' was removed in Rails 3, you need to use 'link_to' with the ':remote => true' attribute.

Re: Update div

I use Rails 3 and 'link_to' with the remote=>true,  without the :remote =>
true the div is updated but the full page, and it does nothing.

What´s the problem??