For update forms I used the following strategy (maybe hackish but it does its dirty work) The submit button is disabled at start. I added (by the controller) to each form control:
- an attribute "initval" containing the stored value - an attribute "isdirty" with default = "false" - an event "onchange" = "SomethingChanged($(this));" For example a text input is rendered like: <input class="string" id="t_customer_f_name" initval="John Doe" isdirty= "false" name="f_name" onchange="SomethingIsChanged($(this));" type="text" value="John Doe" /> In the view there is the following script that toggles the status of the submit button: <script type="text/javascript"> //<!-- function SomethingIsChanged(control){ if( control.attr("value") != control.attr("initval") ){ control.attr('isdirty', 'true'); }else{ control.attr('isdirty', 'false'); } toggleSaveBtn(); }; function toggleSaveBtn(){ $('#sbmt_btn').attr("disabled",!$('#formA').find('*[isdirty="true"]').eq(0 ).size()); }; //--> </script> Il giorno domenica 9 dicembre 2012 17:51:14 UTC+1, Joe Barnhart ha scritto: > > > I've been investigating the use of the DAL feature > "detect_record_change=True". Apparently it was conceived as a way of > detecting when the record in the database has changed since the form was > originally built and populated. My need is for a way to detect when the > USER has changed fields in the record between the time it was built and > some other event, such as when the user tries to navigate away from the > form without pressing the "submit" button. > > It seems to me the idea is quite similar -- I want to serialize the data > in the form and then compare that hash to the same form later. Only > instead of comparing the data in the database to the hash I want to compare > the form's version of the data again. Has anyone already done this? Is > there a better way to detect when a form has actually been changed instead > of just viewed? > > -- Joe B. > --