this is my code:
window.myApp= window.myApp|| {};
myApp.jira = (function () {
var getId = function () {
return ...;
}
var init = function() {
var id = myApp.jira.getId();
}
})();
$(document).ready(function () {
myApp.jira.init(); // here jira is null and getting undefined
});
when the page is loaded it says jira is undefined.
return initat the end of the functionreturn init;will not fix it entirely. It would require different syntax later:myApp.jira(). Or, as in my answer:return { init: init }and rest same as in original code.