Change table row using Rails Ajax

Posted by xopht on Stack Overflow See other posts from Stack Overflow or by xopht
Published on 2010-06-18T06:50:37Z Indexed on 2010/06/18 6:53 UTC
Read the original article Hit count: 219

Filed under:
|

I've a simple page with link_to_remote Rails Ajax function and HTML table. I'd like to change row of the table when click that link.

This is my html.

<table border="1">
    <tr>
        <td><div id="ajax_result_1">1</div></td>
        <div id="ajax_result_2"><td>2</td></div>

    </tr>
    <div id="ajax_result_3">
    <tr>
        <td>3</td>
        <td>4</td>
    </tr>
    </div>
</table>

And this is my code.

<%= link_to_remote 'Change', :update => "ajax_result_1", :url => "change_path" %>

change action just render simple text.

When I use ajax_result_1 for :update, it worked okay.

But, not for *ajax_result_2* and *ajax_result_3*.

Is there a way to solve this? I want to replace row of the table.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about AJAX