Form events

You can listen for events when embedding a Reform. You can use events to show a loading spinner or make an API call with the submitted data.

Currently, the supported events are:

  • onFormLoaded
  • onFormSubmitted
<div id="my-reform"></div>
<script id="reform-script" async src=""></script> 
   Reform('init', {
     url: 'FORM_URL',
     target: '#my-reform',
     background: 'transparent',
     onFormLoaded() {
	console.log('Form loaded')
     async onFormSubmitted(answers) {
	console.log('Form submitted with', answers)

onFormSubmitted receives answers as a parameter. answers is an object with labels as keys and the answer as value. 

onFormSubmitted and custom redirects

If you are using a custom redirect after the form has been submitted you should beware of a caveat using onFormSubmitted. If onFormSubmitted is an asynchronous function it won't redirect until that function has finished executing. You should try to minimize the time it takes to execute the event handler so users won't feel like they are stuck. 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.