I am trying to add a jquery based module to magento 2 via a module. But I keep getting these errors:
ma5menumin.js:1 Uncaught ReferenceError: $ is not defined
at ma5menumin.js:1
callma5.js:1 Uncaught ReferenceError: define is not defined
at callma5.js:1
I think something is wrong with the requirejs-config file but it's a first timer for me, so i'm not sure what to do.
This is the require-js file:
var config = {
map: {
'*': {
"mobilemenu.mobmenu": "Vendor_Module/ma5menumin",
"mobilemenu.callmenu": "Vendor_Module/callma5"
}
}
};
I also tried this require-js:
var config = {
paths: {
"mobilemenu.mobmenu": "Vendor_Module/ma5menumin",
"mobilemenu.callmenu": "Vendor_Module/callma5"
},
shim: {
'mobilemenu.mobmenu': {
'deps': ['jquery']
},
'mobilemenu.callmenu': {
'deps': ['jquery']
}
}
};
This is my callma5.js script:
define(["jquery"], function($){
ma5menu({
position: 'left',
closeOnBodyClick: true
});
});
I also tried this callma5.js:
require([
"jquery"
], function ($) {
//<![CDATA[
$(document).ready(function () {
ma5menu({
position: 'left',
closeOnBodyClick: true
});
});
//]]>
});
The ma5menumin file is minified jquery. How can I load these files after jquery is loaded?