Empty
Hi @RandyPat
Thank you for reaching out.
I want to tag some of our experts here - @Anton @BarryGrennan @nikodev do you have any thoughts for @RandyPat on this?
Thank you!
Best
Tiphaine
For any javascript to affect Hubspot forms, it needs to fire after the form has loaded.
So you need to wrap it in a global event listener.
Specifically the on FormReady listener. e.g.
window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
console.log("Form Loaded!");
/* Your code here */
}
});
It’s also worth noting that the id (#hsForm_d188421e-f948-44e3-8e09-82d74f7ecf6d) will change if you’re using a different form, so it may be more versatile to use a broader identifier (‘form’?) or wrap the form in your calculator module in a uniquely identified div and target via that.
Barry Grennan
