Hello. I'm trying to load a simple regular javascript that's going to be
used as dependency from a RequireJS module.

So i created mytest.js under classpath:META-INF/assets/js/mytest.js. It
contain a single function :

function showMe() {
alert("test 2  my_test");
};

I add the contribution in AppModule

    public static void contributeModuleManager(MappedConfiguration<String,
Object> configuration,
            @Path("/META-INF/assets/js/mytest.js") Resource js) {
        configuration.add("mytest", new JavaScriptModuleConfiguration(js));
    }

Create a test page

@Import(module = "Lima")
public class Lima {
}

that call the module :

require(['mytest'],
function(mytest){
console.log("mytest " + mytest);
mytest.showMe();
});

the module is loaded, the mytest.js file is found. But the console log
mytest as undefined. Here's what's printed on the console

Loading 2 libraries
console.js:104 Loading library
/KomuttaCentral/assets/ctx/z1d218c13/js/jquery-2.0.3.min.js
console.js:104 Loading library
/KomuttaCentral/assets/ctx/z50c3674f/js/scripts.js
console.js:104 Executing 1 inits
console.js:104 Loaded module Lima
console.js:104 All inits executed
Lima.js:3 mytest undefined
console.js:104 RequireJS error: require: Cannot read property 'showMe' of
undefined

So, what did i do wrong? Thanks.
-- 
http://www.mreunionlabs.net/ <http://www.mreunion-labs.net/>
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771

Reply via email to