You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/08/19 16:27:13 UTC
svn commit: r233490 -
/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/resources/js/forms-lib.js
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();
+ }
}
}