Rails: the editor is in place, but there is no postback?

I am using Prototype in a Rails project for in-place editing (via Ajax.InPlaceEditor) of a form. However, I do not want him to immediately send a message and perform an update - the form itself is quite complicated, and the user can decide to abandon his changes. Only now they cannot, because the form invisibly (to them) updated the database.

So what I was going to do was use the Prototype InPlaceEditor without specifying the backlink URL (or making it the common postback URL that returns true), and then as part of the “onLeaveEditMode” for this field, update the hidden form field with new value.

Thus, when the user gets the attractive appearance of the editor in place, but can still click "Cancel" at the bottom and discard all changes.

So, I embarked on this mission in a small test prototype and it seems to work, except that it means a significant amount of javascript code and, in a way, seems to be a trick of the InPlaceEditor target. This should be a problem, but my google-fu doesn't return anything like what I want.

Something like this (but obviously not a grid form) where you can edit the fields in place, but have to click “save” to commit your changes: http://www.nitobi.com/products/grid/ editors /

A 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?

Thank!!

+3
1

. .

  • none. , .
  • .
  • ( ).
  • Blur .

. - css.

jquery JavaScript.: -)

+3

Source: https://habr.com/ru/post/1729508/


All Articles