I’m trying to manipulate the DOM with jquery in the form embed code.
<script>
hbspt.forms.create({
portalId: "xxxxx",
formId: "xxxx",
cssClass: '',
cssRequired: 'form__field required',
errorClass: 'form__field',
errorMessageClass: 'error',
submitButtonClass: 'submitBTN',
onFormReady: function ($form) {
$('form').wrapInner('<div class="form-row form_block"></div>')
$('.hs-form-field').addClass('form-group col-md-12');
$('input').addClass('form__field');
$('label').addClass('form__label');
$(".input input").each(function () {
var e = $(this);
e.parent().parent().find('label').insertAfter(e);
})
}
});
</script>
However, I’m running into an issue.
When a field isn’t valid . Then trying to go back into the field to edit, i get the below JS error
v2.js:4 Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.
at r (v2.js:4)
at Object.processUpdates (v2.js:1)
at Object.dangerouslyProcessChildrenUpdates [as processChildrenUpdates] (v2.js:2)
at s (v2.js:3)
at a.updateChildren (v2.js:3)
at a._updateDOMChildren (v2.js:2)
at a.updateComponent (v2.js:2)
at a.receiveComponent (v2.js:2)
at Object.receiveComponent (v2.js:3)
at u._updateRenderedComponent (v2.js:2)
When I remove the label insertAfter() script those go away