cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Durkin <>
Subject CocoonForms Javascript function displays alert message and can result in Javascript error on IE
Date Mon, 31 Jan 2005 23:55:17 GMT
In the the file:

there's the following code:

// Handlers that are to be called in form's "onsubmit" event
// FIXME: this single var implies only one form per page, and needs to be
//       visited if we decide to support several forms per page.
var forms_onsubmitHandlers = new Array();

function forms_onsubmit() {
     if (forms_onsubmitHandlers == null) {
         alert("onsubmit called twice!");

     for (var i = 0; i < forms_onsubmitHandlers.length; i++) {
     // clear it
     forms_onsubmitHandlers = null;

This code is called when a widget has an on-changed event, a 
selection-list for example.

The problem we've observed is if code called, and the on-value-changed 
event has any lag time ( in our case executing a query against a 
database ) the user can quickly use the selection-list to select another 
option before the 1st selection returned.

This displays the "onsubmit called twice!" alert box.

In Mozilla, that's it, on IE after the alert box there's a javascript 
error.  IE complains about calling  forms_onsubmitHandlers.length  since 
it was set to null;

1.) would anyone object to removing the alert("onsubmit called twice!")?
   - in our case, we'd just prefer to service the second request without 
displaying the alert

2.) should the forms_onsubmitHandlers = null; be changed to 
forms_onsubmitHandlers = new Array(); ?

   - or alternatively, the for loop could be enclosed in the same sort 
of null checking used for the current alert message.

If anyone has a preference for these two issues let me know and I'll 
submit a patch.



View raw message