Automatic Popup Trigger After Form Submission – Kadence Stack

Hello Block Editor Lovers,

In this blog, I will show you how you can trigger a Kadence Conversion Popup, Just after a Successful Kadence Form Submission.

Special Thanks to Sam Jesani, who shared this problem in Kadence Group, It was quite interesting combination so I tried it.

Here is how you do it.

Required Tools:- Only Kadence Blocks Pro

1. Create a Modal Popup

First, create your popup using the Kadence Blocks “Modal” and add Custom ID as “form-popup” as a link.

Note:- You can change the trigger link but you will have to modify the JS given below.

2. Create a Form

Create your form as you want, just make sure not to choose Redirection after submission as this doesn’t make sense as well. Nothing to add custom in Form. (Below JS will work with Kadence Advanced Forms Only)

3. Create a Trigger Button

Create a trigger Button with this class “modal-trigger”. Now add the same link you choose in Modal Trigger, in our case, it’s “#form-popup”.

You also need to use this CSS to hide the trigger button, we will trigger it with JS when form submission is successful.

CSS
.modal-trigger {
    display: none;
}
CSS

4. Use This JS

Now you need to use the JS given below using any Code Snippet Plugin, it’s a very small JS but I will still recommend using it only on the pages where you have Form and want the popup to appear.

This Js checked when the form sends a successful response from Ajax and triggers a Click to the button which has a class

JavaScript
document.addEventListener('DOMContentLoaded', function() {
    // Listen for the successful form submission event
    document.body.addEventListener('kb-advanced-form-success', function() {
        // Find the popup trigger button
        const popupTriggers = document.getElementsByClassName("modal-trigger");

        // Check if the popup trigger exists
        if (popupTriggers.length > 0) {
            // Trigger the Kadence Conversion popup
            const popupTrigger = popupTriggers[0];
            if (popupTrigger instanceof HTMLElement && typeof popupTrigger.click === 'function') {
                const event = new MouseEvent('click', {
                    bubbles: true,
                    cancelable: true,
                    view: window
                });

                // Dispatch the click event
                popupTrigger.dispatchEvent(event);
            }
        }
    });
});
JavaScript

That’s it, it will start triggering the popup as you want.

Subscribe to my Newsletter

If you love my tutorials, consider subscribing to not miss any awesome tips about block editors.

Don't Keep This Magic to Yourself - Share!
Rahul Singh
Rahul Singh

With more than 5 years of wrangling Kadence and Blocksy Themes, plus mastering the Block Editor, I turn complex web design into a breeze. My superpower? Crafting websites that are both fast and fabulous, with a dash of fun and a focus on making conversions soar!

Articles: 8

Leave a Reply

Your email address will not be published. Required fields are marked *