Good way to handle inline-edit form using Rails and jQuery
- by Tim Sullivan
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!