0

I recently started at an environment where the sub module method of JS programming is used exclusively throughout the application. Coming from the wild west of advertising however, I am having a hard time wrapping my head around it. I understand the concepts, which is why it's so frustrating that the following alert never fires:

customNamespace.anotherCustomVar = (function ($, customNamespace) { 
    return {
        init : function () {
            alert(''); // Doesn't fire
        }
    };
})( jQuery, customNamespace );

Looking at another file almost exactly like this, putting an alert in the init fn works fine.

customNamespace.aDifferentCustomVar = (function ($, customNamespace) {
    return {
        init : function () {
             alert(''); // Does fire
        }
    };
})( jQuery, customNamespace );

These are separate js files in the same directory fyi. Does it have something to do with my anotherCustomVar name, if aDifferentCustomVar works?

collin
  • 240
  • 1
  • 3
  • 12
  • Did you call `customNamespace.anotherCustomVar.init()`?, was `customNamespace.aDifferentCustomVar.init()` called. – Musa Jul 20 '12 at 20:53
  • I did not call it, specifically b/c I'm trying to mimic the established workflow. Neither does the one that works though, at least in that file. Is it a matter of hunting down where that init is called? – collin Jul 20 '12 at 21:06
  • 1
    The alert won't fire unless you call `init`, so it has to be called somewhere. – Musa Jul 20 '12 at 21:08
  • there's a global.js that calls all the inits - just a matter if learning this codebase I guess. Cheers! – collin Jul 20 '12 at 21:09

0 Answers0