We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to show a template or reload the page after a form submission?

If you'd like to reload the page after a form is submitted or show the form again with the user's selection shown, you can follow the instructions described below. This way user would be also able to do additional changes in the form if necessary.

Essentially, you have 3 options here, where each offers a different behavior:

  1. Add the following code to your Composer integration code if you want this behavior for all forms:

    window.addEventListener('message', (event) => {
        var ev = JSON.parse(event.data);
        if(ev.event=="formSend"){
            if (ev.sender.startsWith('piano-id-form')){
                location.reload();
        }
     });
    
  2. If you just want this behavior to occur on a specific site, you can add the following code, replacing your website's URL accordingly:

     window.addEventListener('message', (event) => {
        var ev = JSON.parse(event.data);
        if(ev.event=="formSend"){
            if (ev.sender.startsWith('piano-id-form')){
              if(window.location.href == 'https://examplewebsite.com')
                location.reload();
            }
        }
     });
    
  3. If you would like to show a different template after the form submission, you need to add this code instead:

    window.addEventListener('message', (event) => {
        var ev = JSON.parse(event.data);
        if(ev.event=="formSend"){
            if (ev.sender.startsWith('piano-id-form')){
                tp.template.show({'templateId':'<YOUR-TEMPLATE-ID>'})    }
     });
    

    Where you replace with your preferred template.

Last updated: