Error with Hubspot pop-up + embedded form code
Recently deployed a new page using the Hubspot popup + embedded form code. We did identify an error with the snippet generated from that help page, though.
this line of code from the snippet generator:
var fields = document.querySelectorAll("form[data-form-id=\"" + formGuid + "\""] input,select");
was throwing an error and needed to be updated to:
var fields = document.querySelectorAll('form[data-form-id="' + formGuid + '"] input,select');
the
querySelectorAll
method uses double quotes ("
) for the outer string and escapes the double quotes inside the attribute selector with backslashes (\"
). The snippet contains an error in the querySelectorAll
method. The escaped double quote at the end of formGuid
should be before the closing square bracket ]
.
1
-
Hey, Zachary!
Hope this message finds you well! Thanks for bringing this to our attention!
Indeed, the code used in the Snipper Generator had an extra " in the line you shared, causing the error you identified.
We just updated the code with the suggestion you sent in the article itself and the generator.
We apologize if this caused any inconvenience to you!
Wish you a great day ahead!1
Please sign in to leave a comment.
Comments
1 comment