In below code I’m calling myscript.getNum(); but myscript.js throws an error saying
Unexpected Token (
jloader.js
require(["evtManager","myscript"] , function(evtManager , myscript) {
var el = document.getElementById("Clickarea");
evtManager.addEvent(el , "click" , function(){
myscript.getNum();
});
});
myscript.js ->loads myscript2.js and calls a function getValue()
define(["myscript2"], function(myscript2)
{
getNum : function(){ //Throws an error "Unexpected token ("
var x = require("myscript2").getValue();
return 5 + x;
}
});
myscript2.js
define({
getValue : function(){
return 30;
}
})
You probably want myscript.js to return an object similar to this example. I don’t believe you need to require “myscript2” as that has already been done for you: