cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Portier <...@outerthought.org>
Subject Re: cforms forms_onsubmit()
Date Mon, 23 Aug 2004 07:37:02 GMT
Jorg,

I hope you're not serious on wanting to override: there are (well could 
be) functions that cforms really need to be called.

Now, since of course you're likely to have some functions you want to 
call as well, there has been a provisioning for this through the use of 
so called on-submit handlers (functions you can register to be called on 
submit)

Here is how you do it:

by some magic (xslt most probably) you need to make sure you include 
something like the following in the resulting html-page:

   <script language="javascript">
       // making my on-submit...
       var myFSHandler = new Object();
       myFSHandler.forms_onsubmit = function() {
           alert('hello');
       };


       // registring your on-submit
       forms_onsubmitHandlers[forms_onloadHandlers.length] = myFSHandler;
   </script>


the same pattern exists for 'on_load' of the form-page (allowing to 
initialize some stuff)

for the machinery behind this, pls check: 
http://cvs.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/samples/resources/forms-lib.js?rev=36594&root=Apache-SVN&view=auto
(search for onsubmit and onload)

HTH,
-marc=

Jorg Heymans wrote:

> 
> 
> Jorg Heymans wrote:
> 
>> Hi,
>>
>> Is it possible to fully override the onsubmit handler that is 
>> generated by cforms? Cocoon allways puts a forms_onsubmit() infront of 
>> whatever i put in the handler of the form template, causing my 
>> javascript code not to be executed upon submit. The whole of google 
>> has only 2 references to forms_onsubmit() so i am really wondering 
>> what this thing actually does.
> 
> 
> Thanks to the very active google-spider, google now contains 5 
> references to forms_onsubmit() :-)
> 
> Anyone have a clue what this thing actually does?
> my
> 
> <ft:form-template onsubmit="alert('hello')">
> 
> is transformed by cforms to
> 
> <form onsubmit="forms_onsubmit(); alert('hello');">
> 
> causing the alert function not to be executed anymore...
> 
> 
> Regards
> Jorg Heymans
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message