cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Gallardo <agalla...@agssa.net>
Subject Re: ajax cform and forms_onsubmitHandlers issues
Date Wed, 07 Dec 2005 17:29:53 GMT
Quoin Developers wrote:

>I believe that the source of the problem is cforms.js
>
>cocoon.forms.submitForm = function(element, name) {
>...
>            forms_onsubmitHandlers = new Array();
>
>Removing the above line seems to solve the problem. Any reason why
>that line should be there? Can it be removed?
>  
>
The "forms_onsubmitHandlers" JS variable is an event stack. It allows 
form widgets to register one or more events that are triggered before 
the form is submited.

The original implementation (before AJAX) resets the 
"forms_onsubmitHandlers" variable every time the form need to be 
submited back to the server. It helps to detect if the form was already 
submited by the user. It avoids sending twice the request to the server. 
The trick is: when the user press the 1st time te button it ran all the 
events and reset the "forms_onsubmitHandlers" variable to clean up the 
stack, hence when the user press the second time the button there are no 
more events to call.

The above implementation works pretty well in non-AJAX mode, because 
when the user response came, the page do a full reload and every widget 
is allowed to register again the events it needs.

Unfortunately, this does not work in AJAX mode. This is due the AJAX 
nature. AJAX does not make a full page reload. For this reason, the 
widgets that registered an event and don't came back in a response loos 
the onsubmit event. They don't have the opportunity to register again 
his events on the forms_onsubmitHandlers stack. :-(

WDYT?

Best Regards,

Antonio Gallardo.

Mime
View raw message