Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 7936 invoked from network); 19 Aug 2005 14:27:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Aug 2005 14:27:21 -0000 Received: (qmail 61636 invoked by uid 500); 19 Aug 2005 14:27:15 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 61487 invoked by uid 500); 19 Aug 2005 14:27:14 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 61414 invoked by uid 99); 19 Aug 2005 14:27:14 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 19 Aug 2005 07:27:14 -0700 Received: (qmail 7688 invoked by uid 65534); 19 Aug 2005 14:27:13 -0000 Message-ID: <20050819142713.7687.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: cvs@cocoon.apache.org From: sylvain@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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(); + } } }