javascriptjquerydotnetnukedotnetnuke-module

Dotnetnuke Module Javascript Namespace


I have two dotnetnuke Modules with referring Javascript function calling. I wanted to work with this namespace Solution from this Answer Stackoverflow881515 from Jaco Pretorius, which goes back to this Document: Javascript Habits

But my implementation is not working. I've been searching for hours, but can't find the problem. If I call the function ns.testfunc from Module1, then it's working. But from Module2 it isn't working.

My Example Code:

Javascript Code from Module1:

(function(ns, $ , undefined){
    ns.testfunc = function(param){
        alert ("ns.testfunc, param: " + param);
    };
}(window.ns = window.ns || {}, jQuery));

Javascript Code from Module2:

(function (ns, $, undefined) {
    ns.testfunc("call from other .ascx");
}(window.ns = window.ns || {}, jQuery));

But I receive this error:

Unhandled exception at line 241, column 9 in http://localhost:10127/mypage

0x800a01b6 - Laufzeitfehler in JavaScript: Das Objekt unterstützt die Eigenschaft oder Methode "testfunc" nicht


Solution

  • It seems to be another problem with one of the modules which also has third party code. I tried it now with fresh modules and it's working. So I have to dive a little bit deeper...