Page reloads in Vue 3 after form is submitted. | Community
Skip to main content
Aaron_Krug
New Participant
June 16, 2023
Solved

Page reloads in Vue 3 after form is submitted.

  • June 16, 2023
  • 1 reply
  • 2931 views

I am trying to create a Vue 3 Component  for Marketo Form. The form is loading fine and submitting fine but for some reason the page reloads even though I am doing a `return false` in the OnSuccess method. If I change the settings in Marketo for the "Thank you page" to external url from stay on page  it will redirect to that url. It seems the "return false" is being ignored as the alert is displayed when the form is submitted. Thanks you for any help.

 

<template> <form :id="formId"></form> </template> <script> export default { props: { mktoFormId: { type: Number, required: true, }, }, setup(props, { slots }) { const formId = "mktoForm_" + props.mktoFormId; if (window.MktoForms2) { MktoForms2.loadForm( "//app-ab13.marketo.com", "736-VEE-917", props.mktoFormId, function (mktoForm) { mktoForm.onSuccess(function () { alert("Success"); return false; }); } ); MktoForms2.whenReady(function (mktoForm) { console.log("Load"); }); } return { formId, }; }, }; </script>

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Aaron_Krug

Here you go.

https://www.retirepathva.com/contact/subscribe 

The code I posted above is as basic as I could get trying to figure out the problem. This page has more code and should show a success message when submitted.

1 reply

SanfordWhiteman
New Participant
June 16, 2023

Can you link to a page where this is rendered please? Otherwise we have to set up a Vue environment just to test.

Aaron_Krug
Aaron_KrugAuthorAccepted solution
New Participant
June 16, 2023

Here you go.

https://www.retirepathva.com/contact/subscribe 

The code I posted above is as basic as I could get trying to figure out the problem. This page has more code and should show a success message when submitted.

SanfordWhiteman
New Participant
June 16, 2023
Because you have another onSuccess listener loading via GTM, and that one redirects.