Rails3 Jquery link_to

I know that I’m missing something very simple but I setup my
application to use for the links a remote=> true call. In the call it
finds the js.erb file, but doesn’t render into the browser the
content.

LOG:

Started GET “/” for 127.0.0.1 at 2010-06-28 14:26:22 -0700
Processing by HomeController#index as JS
Rendered home/index.js.erb (0.3ms)
Completed 200 OK in 12ms (Views: 11.6ms | ActiveRecord: 0.0ms)

Started GET “/” for 127.0.0.1 at 2010-06-28 14:26:25 -0700
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (2.0ms)
Completed 200 OK in 6ms (Views: 5.6ms | ActiveRecord: 0.0ms)

As you can see in the html.erb it says within the layouts/application
But with the JS call it is missing -
my template looks like this -

  • <%= link_to 'index', :root, :remote=> true %>
  • //This one doesn't render in the template
        <li><a href="/" >Home</a></li>  // This one works
    

    What am I doing wrong?

    The jQuery data-remote tag looks like this -
    $(‘a[data-remote],input[data-remote]’).live(‘click’, function (e)
    {
    $(this).callRemote();
    e.preventDefault();
    });
    $(‘a[data-method]:not([data-remote])’).live(‘click’, function (e){
    var link = $(this),
    href = link.attr(‘href’),
    method = link.attr(‘data-method’),
    form = $(’’),
    metadata_input = ‘’;

        if (csrf_param != null && csrf_token != null) {
          metadata_input += '<input name="'+csrf_param+'"
    

    value="’+csrf_token+’" type=“hidden” />’;
    }

        form.hide()
            .append(metadata_input)
            .appendTo('body');
    
        e.preventDefault();
        form.submit();
    });
    

    Is it missing something?

    Ok I think I’m 1/2 their - I got something to load on the rjs
    template-
    $("#content").html(“fish”);
    Which renders html inside the content tag…
    But it just will render a plain tag for fish - not html code e.g.


    fish

    But I think ideally it would render the same index.html.erb file so I
    wouldn’t have to maintain code in 2 places. Any suggestions how to do
    that?

    Ok I think I figured out a simple version -
    $(’#content’).load(’/clients #index’);
    Right now I have it in my index.js.erb
    but I need to now figure out how to load it into my controller, so I
    can reduce files.