I’ve just started my first project in Blocs and want to test some external CSS and Javascript, but I’m struggling to get the Javascript to work in preview. Here’s what I have done so far:
• Copied the custom HTML to a Code Widget
• Added the CSS and Javascript files to the Project Attachments
The HTML and CSS load and look like they should, but the Javascript functionality isn’t working.
I know the code works because I have used it on another website I built in Bootstrap Studio.
(It’s a loan calculator with sliders to change and calculate a value).
I think I just need to get my head around how Blocs works, so any pointers would be really appreciated.
Welcome to Blocs, I recently started using Blocs as well. Try this,
Copy and paste the javascript calculator controls into the page settings, by going to Page > Settings and click the Add Code button and then select the dropdown for Footer and paste the code in there. Also you can reference a link to the external javascript in the footer, place it before the controls. <script src="./customjs/calculator.js"></script>
“Added the CSS and Javascript files to the Project Attachments”
Make a folder called “customjs” and put your custom javascript in there and attach the folder to the project, that way your js files will be neatly tucked away in the folder structure.
Hopefully this gets it working for you, there maybe a better way.