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)
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
firstRow = document.querySelector('form .mktoFormRow'),
firstRow,
mktoForm,
hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once
hiddenInputCreator = function (tagName, onChangeHandler) {
@ -324,6 +324,7 @@
// need the id of the form so we can hook up autofill
// doing this way will work on any Marketo form
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
form.onSubmit(function (form) {
// tell GA about it, but only if we know they autofilled