Although I’m using Angular.js on the HubSpot TBot page (see Submitting TM users to HubSpot via TBOT interface (using Angular JS) ) I’m still more comfortable/knowledgeable in jQuery, so I decided to use it to populate the HubSpot fields.
So my first action was to load jQuery at the top of the TBot page:
which allowed me to do this:
(note the mix of JQuery and AngularJS code)
But then as I looked through the http://js.hubspot.com/forms/current.js file (which you will also notice that for TM, I saved it on the /_Customizations folder)
In the Util - Javascript Format (and Beautify).h2 O2 Platform tool:
I noticed that they had embedded jQuery in the current.js code, namely at the window.hsJQuery variable
this means that we can use jQuery to access the page’s DOM
Now, if we remove the jQuery script import:
the $ variable will not be available:
But if we assign $ to window.hsJQuery, we are back in action:
Finally, we add that assignment to the TBot page
And the previous code (that used the $) is working again (now using the JQuery version from current.js)