Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Marketo Form Embed to Vue JS Application

I'm trying to add a Marketo form to my Vue Js application but it doesnt seem to be working.

I loaded the initial forms2.min.js script in the created lifecycle hook and that loads just fine. Example code below.

created() {
                  const scriptTag = document.createElement('script');
                  scriptTag.src = "//app-ab00.marketo.com/js/forms2/js/forms2.min.js";
                  scriptTag.setAttribute('charset', 'utf-8');
                  document.head.appendChild(scriptTag);
            }

Within the html template i added the container element to load the form.

<form id="mktoForm_1057"></form>

Then i created a method that gets triggered by a button to load the form into the container.

createForm(){
    MktoForms2.loadForm("//app-ab00.marketo.com", "785-UHP-775", 1057)
}

As soon as i run the script i get this error "MktoForms2 is not defined." Am i doing something wrong?

Would someone be able to help me out?

Thanks!

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

It should be

created() {
    const scriptTag = document.createElement('script');
    scriptTag.src = "//app-ab00.marketo.com/js/forms2/js/forms2.min.js";
    scriptTag.setAttribute('charset', 'utf-8');
    scriptTag.onload = function() {
        MktoForms2.loadForm("//app-ab00.marketo.com", "785-UHP-775", 1057);
    };
    document.head.appendChild(scriptTag);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

It's hitting a snag because MktoForms2 is not defined as a variable. I had to append 'window' to MktoForms2 in order for it to pass linting

window.MktoForms2.loadForm('//app-ab00.marketo.com', '785-UHP-775', 1057)
about 4 years ago · Juan Pablo Isaza Relatório

0

Here is a little snippet I have used for Marketo templates. Make sure you have their forms2.min.js file loaded before using this script. You could also wrap this in a DOM ready/jQuery ready as well.

// check if we have their forms2.min.js script available
if (window.MktoForms2) {
  // error handling
  try {
    MktoForms2.loadForm(baseUrl, munchkin_id, formId, function(form) {
      // code to execute after load form
    });
    MktoForms2.whenRendered(function(a) {
      // code to execute after the form has rendered its markup
      var fid = a.getId(); // form id
    });
  } catch (a) {
    console.log(a);
  }
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda