I've been trying to add a custom script to my Magento stores, however I can't get it to load. I've created the js file in my web/js folder in my theme, and added it to the theme's requirejs file. It will also load the file into the static folder eventually, but it doesn't work at all.
This is the js file I've been trying to load for testing purposes:
define([
'jquery',
'jquery/ui'], function($) {
alert('start openMenu');
$.widget('rvdk.openMenu', {
_create: function() {
alert('open-menu.js');
console.log('open-menu.js');
$(window).on("scroll", function () {
alert('open-menu-scroll.js');
});
}
});
return $.rvdk.openMenu;
});
requirejs-config:
var config = {
map: {
'*': {
'open-menu' : 'js/open-menu',
'header' : 'js/header',
'products-masonry' : 'js/products-masonry',
'image-grid' : 'js/image-grid',
}
}};
It loads a few more files, but I don't think those are important. Header.js works fine for example, and I can change this file and the changes will be displayed. However it still doesn't load open-menu.js, even though it is in the static files.