I trying to use the module pattern with JS. But when I call HM.init() in the console, it says undefined. It's like this.carousel doesn't exist at all. Why is that?
JS:
(function(window, $){
var HM = (function (HM) {
HM.init = function(){
this.carousel.init();
}
return HM;
})(HM || {});
window.HM = HM;
$(function(){
console.log(HM.init()); // this doesn't work
});
})(window, jQuery);
//Extending module (this is supposed to be in another file)
(function(window, HM, $){
HM.carousel = {
init: function(){
return 'initialise HM';
}
}
})(window, HM, jQuery);.
Many thanks