cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r233490 - /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js
Date Fri, 19 Aug 2005 14:27:13 GMT
Author: sylvain
Date: Fri Aug 19 07:27:10 2005
New Revision: 233490

URL: http://svn.apache.org/viewcvs?rev=233490&view=rev
Log:
Fixing the "onsubmit called twice" problem

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js?rev=233490&r1=233489&r2=233490&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js
Fri Aug 19 07:27:10 2005
@@ -38,15 +38,20 @@
 
 function forms_onsubmit() {
     if (forms_onsubmitHandlers == null) {
-        alert("onsubmit called twice!");
-        return;
+        // Form already submited, but the new page is not yet loaded. This can happen when
+        // the focus is in an input with an "onchange" and the user clicks on a submit button.
+        return false;
     }
 
     for (var i = 0; i < forms_onsubmitHandlers.length; i++) {
-        forms_onsubmitHandlers[i].forms_onsubmit();
+        if (forms_onsubmitHandlers[i].forms_onsubmit() == false) {
+            // handler cancels the submit
+            return false;
+        	}
     }
     // clear it
     forms_onsubmitHandlers = null;
+    return true;
 }
 
 /**
@@ -64,8 +69,9 @@
     } else {
         form["forms_submit_id"].value = name;
         // FIXME: programmatically submitting the form doesn't trigger onsubmit ? (both in
IE and Moz)
-        forms_onsubmit();
-        form.submit();
+        if (forms_onsubmit()) {
+            form.submit();
+        }
     }
 }
 



Mime
View raw message