Please read the Require.js documentation about this. You just cannot use
Require.js with non AMD .js files and expect it to work without no further
work.
On Sat, 14 Feb 2015 14:04:36 -0200, abangkis <abang...@gmail.com> wrote:
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.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org