SOLVED

Error When Using Marketo Form in Elementor PopUp

Go to solution
sethanderson
Level 1

Error When Using Marketo Form in Elementor PopUp

We are using a Marketo form on our site as our Demo form, and have built it to hide most of the fields until the email address is entered and Clearbit can check before revealing any more unknown fields. This works totally fine when the form is embedded on the site - however when we embed the form as a popup in Elementor we sometimes experience issues where we see two forms render at once or show all the fields without hiding them as expected.

When this happens we see the following error:
Screen Shot 2024-03-15 at 12.50.42 PM.png

Has anyone else experienced issues when embedding a Marketo form with hidden fields into an Elementor popup?

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Error When Using Marketo Form in Elementor PopUp

The cause: when the lightbox loads on button click, it’s reinjecting the lightbox-able child content into the DOM — and deliberately re-running the code in child <script> elements.

 

So even though there’s already a fully-formed Marketo <form> element, MktoForms2.loadForm() runs again and stacks another set of the same fields underneath (this is expected if you run loadForm() again for the same form ID).

 

You need to make sure loadForm() only runs once per ID, simply wrapping the existing <form> in the lightbox. This is better for performance as well.

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Error When Using Marketo Form in Elementor PopUp

You’ll need to link to your page. There’s no way to make any recommendations without that.

 

Please include steps to reproduce the problem, if you have them.

sethanderson
Level 1

Re: Error When Using Marketo Form in Elementor PopUp

Here is the page: https://codesignal.com/pricing 

This occurs when clicking the 'Contact Sales' CTAs. If it doesn't happen upon the first click it will usually happen after refreshing the page a few times.

Thank you!


SanfordWhiteman
Level 10 - Community Moderator

Re: Error When Using Marketo Form in Elementor PopUp

The cause: when the lightbox loads on button click, it’s reinjecting the lightbox-able child content into the DOM — and deliberately re-running the code in child <script> elements.

 

So even though there’s already a fully-formed Marketo <form> element, MktoForms2.loadForm() runs again and stacks another set of the same fields underneath (this is expected if you run loadForm() again for the same form ID).

 

You need to make sure loadForm() only runs once per ID, simply wrapping the existing <form> in the lightbox. This is better for performance as well.