Good way to handle inline editing form using Rails and jQuery

I have a list of items displayed in a DIV series. When someone clicks on the "edit" link, I want to replace the div with a form that allows them to correctly edit the contents of this element.

I am trying to think of an ideal way to handle this. Create a hidden edit form for each item in the list and link the edit link to open it, for example:

<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 get the data and paste the HTML form in the right place? Remember, I use jQuery, so I cannot use prototype helpers.

Thanks!

+5
source share
3 answers

- , , Railscasts. jQuery Rails. , , .

ajax , javascript . , , !

+6

- . , -, - ? jeditable.

, . , , jQuery, , . , , .

+2

, , : jquery edit in place

http://davehauenstein.com/code/jquery-edit-in-place/example/ http://code.google.com/p/jquery-in-place-editor/

, . .

, , jquery ajax load. , .

http://docs.jquery.com/Ajax/load

$('.yourlinkid').click(function(){
   var id = $(this).attr('id');
   $("div#editThisDiv").load("/events/editAjax/" + id);
});
+2

All Articles