bug: form not always avail looking for 1st row

This commit is contained in:
Cappy Popp 2021-01-07 10:37:16 -05:00
parent a825ad30f2
commit 7c7daafbe3

View File

@ -3,7 +3,7 @@
var fillScript = document.createElement('script'), // the LI autofill script (client-side) var fillScript = document.createElement('script'), // the LI autofill script (client-side)
iframeHolderDiv = document.createElement('div'), // so we can style location of button iframeHolderDiv = document.createElement('div'), // so we can style location of button
autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page
firstRow = document.querySelector('form .mktoFormRow'), firstRow,
mktoForm, mktoForm,
hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once
hiddenInputCreator = function (tagName, onChangeHandler) { hiddenInputCreator = function (tagName, onChangeHandler) {
@ -324,6 +324,7 @@
// need the id of the form so we can hook up autofill // need the id of the form so we can hook up autofill
// doing this way will work on any Marketo form // doing this way will work on any Marketo form
fillScript.setAttribute('data-form', 'mktoForm_' + form.getId()); fillScript.setAttribute('data-form', 'mktoForm_' + form.getId());
firstRow = document.querySelector('form .mktoFormRow'); // so we can use it above
mktoForm = form; // so we can use it above mktoForm = form; // so we can use it above
form.onSubmit(function (form) { form.onSubmit(function (form) {
// tell GA about it, but only if we know they autofilled // tell GA about it, but only if we know they autofilled