How to close a popup with a marketo form after form is submitted?

Kat_Narvaez
Level 2

How to close a popup with a marketo form after form is submitted?

Hello,

I have a Marketo form embedded on a popup in our site, using a Wordpress plugin (popup maker). When someone submits the form, I'd like the popup to close and stay on the current page. I'm basically trying to do the same thing here: http://developers.marketo.com/blog/hide-lightbox-after-form-submission/  but instead of using the marketo lightbox, I'm embedding the form in our own popup. Has anyone tried/done this?

Thanks,

Kat

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: How to close a popup with a marketo form after form is submitted?

Of course: just call your popup/lightbox library's close method in MktoForms2.onSuccess.

Kat_Narvaez
Level 2

Re: How to close a popup with a marketo form after form is submitted?

I tried that but the form it's still doing whatever I set up on my form inside Marketo. This is my code:

<script src="//app-ab19.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_1335"></form>

<script>MktoForms2.loadForm("//app-ab19.marketo.com", "497-SKV-262", 1335, function (form){form.onSuccess(function(){jQuery('#popmake-1310').popmake('close');});});</script>

SanfordWhiteman
Level 10 - Community Moderator

Re: How to close a popup with a marketo form after form is submitted?

That's​ a different question. If you want to suppress the default success action (that is, redirecting to the Thank You URL) then return false in onSuccess after closing the lightbox.

Kat_Narvaez
Level 2

Re: How to close a popup with a marketo form after form is submitted?

Ok, it worked. I was making a dumb mistake. Thank you Sanford!