loadForm wrapped with Requirejs

Anonymous
Not applicable

loadForm wrapped with Requirejs

I'm trying to use the Forms 2.0 API to load a form. I'm also using require.js on my site to handle my JS async packages. When I run my callback I'm getting an error in the console from Marketo saying that my supplied Munchkin ID isn't valid. Any idea what dependancy is screwing this up? Note: I've ommitted my actual ID in the samples.

Error:
Error loading form: Object {error: true, errorCode: 400, message: "Subscriber '###-XXX-###' is not valid"}

Require.js sample:
// Marketo
require(["marketo"], function(MktoForms2){
MktoForms2.loadForm("//app-sjqe.marketo.com", "###-XXX-###", ####);
});
Tags (1)
3 REPLIES 3
Anonymous
Not applicable

Re: loadForm wrapped with Requirejs

Please open a support ticket about this. 
Anonymous
Not applicable

Re: loadForm wrapped with Requirejs

I've seen a similar situation, where forms2.js won't work if require.js has run first.
This is preventing marketers from pasting the embed code into arbitrary page bodies in our cms.
The only workaround (less than ideal) I've found is to load forms2.js (minifed version) first on all pages of the site.

What was the resolution of the support ticket?
Anonymous
Not applicable

Re: loadForm wrapped with Requirejs

Looking back, I don't know what exactly the issue of the fix was. I filed a ticket that has a closed status, but has no comments or activity on it. I don't remember if I figured it out on my own or what. The relevant bits of code are below. Let me know if you have any specific questions.

require.config({
    paths: {
        "marketo": "//app-sjqe.marketo.com/js/forms2/js/forms2",
    },
});

require(["marketo-form"], function(util){});

// In marketo-form.js
define([
    "marketo"
], function(MktoForms2){
// Custom code to look for forms on page and init
});