cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Re: RFC: Changes to CForms in 2.1.11-dev
Date Thu, 28 Dec 2006 13:11:51 GMT

On 28 Dec 2006, at 12:01, Jeremy Quinn wrote:

>
>> And does the new stuff better support multiple forms on one page. I
>> think there are some problems with the current onsubmit handlers when
>> there is more than one form.
>
> Yes, I had to change the API for adding submit handlers to allow  
> for more than one form per page.
>
> Instead of this :
>
> 	forms_onsubmitHandlers.push(handler)
>
> You would have to do this :
>
> 	cocoon.forms.addOnSubmitHandler(formID, handler)

A quick correction, the new function is this :

cocoon.forms.addOnSubmitHandler = function(elt, handler)

Where 'elt' is the Element that is adding the handler.


cocoon.forms.addOnSubmitHandler = function(elt, handler) {
     if (typeof(handler.forms_onsubmit) == "function") {
         var form = this.getForm(elt);
         if (form) {
             var id = form.getAttribute("id");
             if (id) {
                 if (!cocoon.forms.onSubmitHandlers[id])  
cocoon.forms.onSubmitHandlers[id] = new Array();
                 cocoon.forms.onSubmitHandlers[id].push(handler);
             } else {
                 if (dojo) dojo.debug("WARNING: SubmitHandler not  
added. There is no id attribute on your form.");
             }
         }
     }
}


regards Jeremy
Mime
View raw message