Form handling

I am building a tree-like list on my page. I'd like to offer the user functionality to edit data associated with a subset of list items by providing an <edit> link to a form. When a user wants to edit an item, a form should be displayed in place of the list. When the form is submitted the list should be redisplayed, ideally as it was and without the need to refresh it from the database. NB, the data edited is not displayed in the list so a refresh is not required.

I'd be grateful for some tips on how I might achieve this.

Thanks, Lee.

There is a: form_remote_tag(options = {}) in the Rail API it creates a form which will be submited via XMLHttpRequest. So you need to create such a remote form. Then link your edit_link to a javascript function you may use link_to_function from the Rails API for this purpose. The function you're calling should toggle between the form and the list display e.g. via Prototype Element.toggle('list_id'); Element.toggle('form_id'); Now you see the form instead of the list. Your function should also set some value in the form to determine which edit_link was clicked on. You may have to replace the remote form with your own version (just look at the source and copy it) bc I don't see a default way to toggle back to our list after submit. So you may have to add this yourself. E.g. After your XMLHttpRequest was successfull use Element.toggle again to switch back.

Daniel