I'm having problems getting JS modules to execute. I've followed the outlined examples and created a custom module called menu.js and inserted it as data-module attribute like so <div class="mobile-menu-button" data-module="menu"> but it's not working. I've tried to just alert/console.log something in menu.js and that does not work as well. I did not touch the app.js or index.js file but still doesn't seem to work.
I can see that when I build the project (using Blendid in combination with CraftCMS) that module gets built but it does not execute. Is there some specific way I should be calling/including modules for them to work?
Basically, in this example I want to execute menu.js module when user click on HTML element mentioned above. Here's the full menu.js code:
Hi everyone,
I'm having problems getting JS modules to execute. I've followed the outlined examples and created a custom module called
menu.js
and inserted it asdata-module
attribute like so<div class="mobile-menu-button" data-module="menu">
but it's not working. I've tried to just alert/console.log something in menu.js and that does not work as well. I did not touch theapp.js
orindex.js
file but still doesn't seem to work.I can see that when I build the project (using Blendid in combination with CraftCMS) that module gets built but it does not execute. Is there some specific way I should be calling/including modules for them to work?
Basically, in this example I want to execute menu.js module when user click on HTML element mentioned above. Here's the full menu.js code:
https://gist.github.com/mladimatija/84956fd9203f283a525a56bc3fbb0c9f
Any help would be greatly appreciated!
Thanks