I want to access methods related to modal in another js file. So I created a global object called app and created methods like so:
//global variables
app = {};
//modal components
app.modal = function ( ele ) {
return {
"closeModal": function() {
$('.modal.fade').removeClass("in");
$(".browser .overlay").removeClass("show");
}
}
}();
Then to access the closeModal method, I basically call app.modal.closeModal()
in a *.js file. But I am getting the following error message:
Exception in setTimeout callback: TypeError: app.modal.closeModal is not a function
I have been staring at this for a while but cannot seem to see where the issue is. I bet I am doing something really stupid.
Thanks for your help.