On 6/8/06, Craig White <craigwhite@azapple.com>
wrote:> I didn''t get much traction on this so I am trying again...
>
> I am working on an application where there are many different screens to
> access the data in a particular record/row. I have links to each data
> entry screen at the top. Is there a way to detect whether the current
> hash has been changed from the stored record so I can prompt the user if
> they attempt to change screens without having saved their changes to the
> data?
>
> I have added a field to my db called ''updated_at'' and the
db in the
> value is put into the current hash...but that value doesn''t change
if I
> change another value on an input screen - unless I save, which of course
> is what I am trying to detect...the need to save.
>
> Is there a method for doing this?
>
> Craig
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
If I understand your question, it seems the most optimized way (unless
your''e keeping track of a huge amount of data) is to store the current
values in JavaScript on the browser end. Then you can have a simple JS
callback to check if the user changed anything. I did this in other
frameworks before I switched to Rails, so I don''t know if
there''s any
help in Rails for doing that (but I guess there is).
The other option is, instead of sending all the db values to the
browiser in the beginning, to "call home" and check the current form
values against the database, via an AJAX call. It would obviously be
less fast than the former way, but might be seen as more elegant and
DRY, especially if there''s a lot of information in these forms, and
the user is likely to just change a bit of it.
--
-Alder