Using Ajax (Prototype) to Update Form fields + Resulting page Simultaneously

Ok, so I found a good example online that does what I want to do. On Youtube, if you view a video that you own, there's a button available "EDIT DETAILS" and upon clicking that it makes the Title and Description Editable text fields.

I'd like to make an update button on a posts page I have and have the same thing occur, the title and content become text fields which can then be saved. I just have no idea how to do it though. Any help is greatly appreciated!


Hi Bazz,

You can try having a hidden edit form for the model on the same page, say with the div id of "form". On clicking the "Edit Details" link, use JS to hide the current div and display the "form" div instead. This div will have the complete form which will submit via AJAX. This is if you would like to have your own solution.

Alternatively, you could use the in_place_editor for Rails - .

Good luck!

Thanks for the help Ram!! I'm going to try to implement this when I have some time. I'll let you know how it goes :slight_smile: