Good way to handle inline-edit form using Rails and jQuery

Posted by Tim Sullivan on Stack Overflow See other posts from Stack Overflow or by Tim Sullivan
Published on 2009-04-23T23:28:26Z Indexed on 2010/04/14 18:23 UTC
Read the original article Hit count: 342

Filed under:
|

I have a list of items, being displayed in a series of DIVs. When someone clicks on an "edit" link, I want to replace the div with a form that will let them edit the contents of that item in a nice way.

I'm trying to think of the ideal way to handle this. Do I create a hidden edit form for every item in the list, and hook the edit link to reveal it, like this:

<div>
    <a href="#">edit</a> Item One
    <div id="edit_1202" class="editform">Edit form goes here</div>
</div>
<div>
    <a href="#">edit</a> Item Two
    <div id="edit_2318" class="editform">Edit form goes here</div>
</div>

Or is there a better way to fetch the data and insert the form's HTML into the right spot? Remember, I'm using jQuery, so I can't use the prototype helpers.

Thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails