I'm using Prototype in my Rails project to do in-place editing (via Ajax.InPlaceEditor) of a form. However, I don't want it to immediately post back and do the update - the form itself is pretty complicated and the user may decide to abandon their changes. Only now they can't, because the form has invisibly (to them) updated the database.
So, what I was thinking of doing was using Prototype InPlaceEditor without specifying a postback url (or make it a generic postback url that returns true) and then as part of the "onLeaveEditMode" for the field, have it update a hidden form field with the new value.
That way, when the user gets the fancy look and feel of an in-place editor but still can press "Cancel" at the bottom and undo all the changes.
So, I've embarked on this mission in a little test prototype and it seems to work -- except it means a substantial amount of javascript code and, in a way, feels like bastardizing the InPlaceEditor purpose. This has to be a solved problem but my google-fu doesn't return anything quite like I want.
Something kind of like this (but obviously not a grid form) where you can in-place edit the fields but must press "save" to commit your changes: http://www.nitobi.com/products/grid/editors/
Couple of questions: 1) Is there an existing rails plugin or Prototype class to do this for me? 2) If not, does my approach sound reasonable?
Thanks!!
If you just want fancy feel of inline editing. Fake it.
You don't need ghost hidden fields. And most of the stuff is css.
Use jquery to minimize javascript code. :-)