AnsweredAssumed Answered

How to add onsubmit type functionality to forms?

Question asked by fiferyan on Nov 23, 2010
Latest reply on Dec 6, 2010 by stevegreenbaum
I'm scratching my head a bit here on the best way to add onsubmit-type handling to forms in Share.  I have a custom control that is a WYSIWYG editor and I'd like to copy the contents of the editor out to the standard content form field textarea on the inline-edit page before running through the normal validation/submit procedure.

I can see a few different ways to do it but wondered what the Alfresco-recommended way is. Here are my ideas so far:
  • Update the contents every n milliseconds using setTimeout (not my favourite because it introduces potential race conditions)

  • Add a custom validation method that simply copies the text between the two and returns true

  • Add an event listener to the form that copies the data when the form is submitted (using Alfresco.util.ComponentManager.get(myFormId))

  • Add an event listener to copy the data when the editor loses focus
Are one of these a better approach than another or is there yet another way that I'm missing?