@dan or @ben I spent a bunch of time this morning with Mr. Bot trying to figure out how to get the JS code for my custom component integrated into a DevPack component. We encountered numerous issues that appear to require the assistance of the Big Guns.
All of the properties and the HTML code for the component work just fine, but the JS code never appears to be called. The file is loaded and is set up in the hooks.js file in the components file hierarchy.
Is there any way I can get some help on making this work?
i’ve also had problems adding JS code to my projects lately. after many tests (and asking the elementi-bot!), i now put my JS-code in a separate file, like Dan shows in his video.
@dan Yes, I already have the code in place for this, but the problem we encountered was that the {{assetPath}} appeared not to be returning the correct path to the asset, which is why the bot flagged it as a bug in our attempt to get this working.
Of course, because the path was incorrect, the JS code could not be found. It did appear as if the JS file was being loaded, though.
Did you include the JS code with or without <script> </script> in the JS file?
For me, it only works without it. Otherwise, the script doesn’t output anything.
@Pegasus you don’t need to edit the site template, you can use Portal to add code into the head area.
That way you can make your component work when placing it in any site
btw. You also shouldn’t be hard coding paths, this is almost ALWAYS a bad idea…
@handshaper I don’t think there is a bug in {{assetPath}} we use it ourselves, so I wonder if you’re not quite using it correctly… if you share code with us we can take a look and point you in the right direction
I will have to move this eventually because the code is shared with the other component that is part of the pack. But for now I just want to get this one component working properly.
Is there perhaps an explainer video about this? Honestly, half of the time I have no idea what I’m building with the help of the “elementi-bot” or how I manage to get it working at all.
i’m more the type to try, fail, learn, and then start all over again until it finally works somehow.
So a video on how to use that “portal feature” would be super helpful for someone like me!
I tried that and it did not work either. I hope someone can shed some light on this as it is very frustrating having everything working except the code that makes it all happen.
@dan I’m still having no luck getting this working, so I could really use some help to understand what is wrong that isn’t allowing the JS code to work.
@dan OK, because I was having no luck integrating a separate JS file I decided to go with a different approach. Instead, I added the code as a script inside the HTML code and then moved it to the appropriate location using the portal code.
So far, this approach seems to be working, so now I have a working DevPack for my privacy consent stuff. Yippee!