Jun 18, 20184:57 AM - edited Jun 18, 20185:50 AM
Member
How do I access a variable from my custom module, in a global JS file?
Hi,
I've already read a lot of posts about this, but can't seem to find one, that solves my problem or maybe I don't understand it correctly.
I want to access a field inside my custom module BEFORE it renders, from a global JS file. Is that possible?
Like use {{widget.name_of_module_field}} inside another JS file, so I can manipulate with it.
I have then read about export_to_template_context, but I'm not sure if that solves my problem?
If so, read the following: I've created a custom module where I want to set export_to_template_context to true, in a drag and drop template, but I don't know where to do so.
But as I understand it, you can only do this, if you're coding the template in HTML+HubL whereas I'm using Hubspot drag and drop template. I might have misunderstood it.
Unfortunately, no, HUBL is compiled on the server side whereas JS is on the client side. Perhaps you can take a step back and tell us what the ultimate functionality you are trying to achieve is, and we can help you come up with other creative solutions to get that task done.