Found the problem...we had some code in a related .script that was firing after 
the page had fully loaded.  This script code modified some text field values 
(blanked them out if a related select field was set to a certain value) after 
the dirtyFormWarning had already taken its 'hash' value of the form.  When the 
user tried leaving the page the original form's hash value was now different 
because the text field was set to blank.  Just thought I'd share in case anyone 
has the same problem going forward.  
 

________________________________

From: [EMAIL PROTECTED] on behalf of John Corro
Sent: Tue 12/12/2006 1:17 PM
To: tacos-devel@lists.sourceforge.net
Subject: [Tacos-devel] DirtyFormWarning firing on clean form


I'm trying to leverage the DirtyFormWarning, but am finding that the warning 
dialog box is being displayed even if no changes are being made to the HTML 
form.  I don't know why this might be happening and tried looking at some of 
the resulting HTML/Javascript code to get some better insight.  The only thing 
that I found strange was that javascript variable 'dirtyFormWarming' was 
initially set to true....here's a code snip of the HTML output:
var dirtyFormWarning = true;

function setDirtyFormWarning(enabled) {
        dirtyFormWarning = enabled;
}

window.onbeforeunload = function(evt) {

        if (dirtyFormWarning) {
                
                
                        var currentFormValue = 
dojo.io.encodeForm(dojo.byId("AddDailyPatientForm"));
                        if (initialFormValue != currentFormValue) {
                                return "You have unsaved changes.";
                        }
                                
        }
        setDirtyFormWarning(true);
};

I would've thought that 'dirtyFormWarning' would've been initialized to 
'false'?  With it being initialized to 'true' I can see why the warning dialog 
is always being displayed w/o the user having done anything.  Btw, the 
'forceWarning' attribute is not being used (just the 'form' and 'message' 
attributes). 

Is there any common/typical culprits that cause this behavior?  Is there anyway 
I can initialize the 'dirtyFormWarning' javascript variable to false?  If 
there's any help or direction someone can point me in, I'd be very grateful.  
Thanks in advance!

 

john




<<winmail.dat>>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Tacos-devel mailing list
Tacos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tacos-devel

Reply via email to